Hey, I am new here and was wondering if someone more knowledgeable could give me a couple pointers... I think the problem has to do with the scanf() function and improper coding, but I cannot figure out what I am doing wrong.
The requirements are:
Calculate the volume of snow, in cubic feet, that it would take to build a snowman, made of 3 round snowballs.
Read the diameter of the top, middle, and bottom snowballs from the user in inches. Calculate the volume of each required snowball and the total volume and print all 4 values, with appropriate labels and exactly 1 decimal place. Use a constant to hold the number of inches in 1 foot.
/* Snowman program */
#include <stdio.h>
#include <math.h>
#define PI 3.141593
int main(void)
{
double x, y, z; //x= bottom diameter, y= middle diameter, z= top diameter
double Vol_Bot;
double Vol_Mid;
double Vol_Top;
double Vol_Tot;
/*Asks for the bottom, middle, and top diameters*/
printf("Enter the value for the bottom, middle, and top diameters>");
scanf("%lf", &x);
scanf("%lf", &y);
scanf("%lf", &z);
What IDE are you using? It should give you load of warnings.
1) Send to printf actual variables, not the pointer to them (get rid of "&" before function argument)
2) Gcc gives me a warning on "%lf" in printf and working incorrectly. if you will have problems with that, change it to "%f".
The problem is in your printf statements. You're passing the address of Vol_Bot, Vol_Mid and Vol_Top. You should be passing the values, not the addresses.