#include<stdio.h>
#include<conio.h>
                 int main(){
                     float Area;
                     float r,h;
                   #define pi 3.41;
                     
                     printf("enter the radius of the  circle in centimeters\n");
                     scanf("%f",&r);
                     
                     printf("enter the height of the cilinder in centimeters\n");
                     scanf("%f",&h);
                     
                     Area=(pi*r*r)+(pi*r*h);
                     
                     printf("THE AREA OF THE CILINDER IS:%f",&Area);
                     return 0; 
                     getch();
                     }

Here is the problem

printf("THE AREA OF THE CILINDER IS:%f",&Area);

Why u use &Area ? Its a refrence type.

Use only Area to solve this....

printf("THE AREA OF THE CILINDER IS:%f",Area);

Edited 4 Years Ago by kingsonprisonic: n/a

Never mind executing, this code doesn't even compile.

Pay attention to your compiler's output. Errors and warnings are there for a reason; they are usually trying to tell you something important. Please post them with your questions; this will help us help you.

Problem 1:

int main() {
    float Area;
    float r, h;
#define pi 3.41;

Don't put a semicolon at the end of the definition. It will be repeated every time you use it, which means that this line...

Area = (pi * r * r) + (pi * r * h);

...is preprocessed into...

Area = (3.41; * r * r) + (3.41; * r * h);

...which doesn't do you any good.

Also, the definition of pi should go outside of main() . It will work where it is, but having it at the top of the file by your includes makes everything easier to read and understand. Also consider capitalizing the whole thing (i.e., PI )--there's nothing wrong with lowercase letters, but it is a widespread convention to put C macro definitions in all caps, so that they may easily be identified as such.

Problem 2:

printf("THE AREA OF THE CILINDER IS:%f", &Area);

Don't pass addresses to printf unless you want to print the address. You want to just use Area here.

Problem 3:

return 0;
    getch();
}

That call to getch() will never happen. A return statement should always be the very last thing in main() .

This article has been dead for over six months. Start a new discussion instead.