Choices using the if statements
What this program should do is to enter radius then pick choices....
but it doesn't seem to work
the problem lies with the choice part in which when you type A or a, it will output the radius... when you type B or b circumference... and for C and c --- the area...
Code:
#include <stdio.h>
#include <conio.h>
#define PI 3.14159
int main(void)
{
float r,circ,area;
char c;
clrscr();
printf ("Input Radius:");
scanf ("%f",&r);
printf ("Enter Your Choice\n");
printf ("\n[a] Radius");
printf ("\n[b] circumference");
printf ("\n[c] Area of Circle\n");
scanf ("%f",&c);
c = getche();
if (c == 'a' || c == 'A') {
gotoxy (38,12);
printf ("The radius of the circle is %f", r);
}
else if (c == 'b' || c == 'B') {
gotoxy (38,12);
circ = 2 * PI * r;
printf ("Circumference: %f", circ);
}
else if ( c== 'c' || c== 'C') {
gotoxy (38,12);
area = PI * r *r;
printf ("Area: %f", area);
}
else
{
gotoxy (38,12);
printf ("Invalid Choice");
}
getch();
}