![]() |
| | #1 |
| Registered User Join Date: Sep 2009
Posts: 32
| For some reason, it's giving me the wrong answer: Code:
#include <stdio.h>
#define PI 3.14159
#define SNOW_DEN 0.1
double Sphere_Volume( double radius);
double Sphere_Mass (double den, double volume);
int main() {
int radius_1, radius_2, radius_3;
double total_volume;
double total_mass;
printf("What is the radii of the head, body and leg of the snowman?\n");
scanf("%lf%lf%lf", &radius_1, &radius_2, &radius_3);
total_volume= Sphere_Volume(radius_1)+ Sphere_Volume(radius_2) + Sphere_Volume(radius_3);
total_mass= Sphere_Mass(SNOW_DEN, total_volume);
printf("The total Mass in grams is %lf.\n", total_mass);
system("PAUSE");
return 0;
}
double Sphere_Volume( double radius){
return 4*PI/3*radius*radius*radius;
}
double Sphere_Mass (double den, double volume){
return SNOW_DEN*volume;
}
Where am I doing wrong? |
| Neotriz is offline | |
| | #2 |
| a_capitalist_story Join Date: Dec 2007
Posts: 1,061
| Turning up your warnings may have helped: Code: snowman.c:16: warning: format ‘%lf’ expects type ‘double *’, but argument 2 has type ‘int *’ snowman.c:16: warning: format ‘%lf’ expects type ‘double *’, but argument 3 has type ‘int *’ snowman.c:16: warning: format ‘%lf’ expects type ‘double *’, but argument 4 has type ‘int *’ |
| rags_to_riches is offline | |
| | #3 | |
| Registered User Join Date: Sep 2009
Posts: 32
| Quote:
How do you turn up the warnings? | |
| Neotriz is offline | |
| | #4 |
| a_capitalist_story Join Date: Dec 2007
Posts: 1,061
| Depends on the compiler. I used gcc, so I used Code: gcc -Wall -pedantic -std=c99 -o snowman snowman.c Code: snowman.c:23: warning: implicit declaration of function ‘system’ |
| rags_to_riches is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with basic calculation program. | StateofMind | C Programming | 18 | 03-06-2009 01:44 AM |
| Help with day of the week program | Punkakitty | C++ Programming | 10 | 01-14-2009 06:55 PM |
| I'm so close to finishing this...please help with logic error | crazychile | C Programming | 8 | 11-03-2008 09:48 PM |
| The Timing is incorret | Drew | C++ Programming | 5 | 08-28-2003 04:57 PM |
| Another Calendar/Birthday Question-Please help- SORRY! | dauz | C Programming | 4 | 04-22-2003 12:52 PM |