Thursday, 10 March 2016

C Program For Finding Radius Circumference Using Switch Case

#include

int main()
{
//Ghanendra Yadav
float radius=0.0,height=0.0;
char choice,quit;
const float pi=3.1415658;

do
{
printf("Enter radius : \n");
scanf("%f",&radius);

printf("\n\nWhat do you want to calc.?\nArea of circuit --> press A\n"
"Circumference of circuit --> press C\nVolume of cylinder --> press V\nQuit --> Q\n");

scanf("%c",&choice);

switch (choice)
{
case 'A':
   printf("Area = %.5f\n",radius*radius*pi);
   break;
case 'C':
   printf("Circumference = %.5f\n",2*radius*pi);
   break;
case 'V':
    printf("Enter Hight : \n");
    scanf("%f",&height);
   printf("Volume of cylinder = %.5f\n",radius*radius*pi*height);
   break;
case 'Q':
    quit='y';
   break;
default:
    printf("default!!\n");
   break;
}
}while(quit != 'y');

return 0;
}

Output:-


No comments:
Write comments

Recommended Posts × +