C programming Please take care of all the conditions. I don\'t mind if it takes
ID: 3594591 • Letter: C
Question
C programming
Please take care of all the conditions. I don't mind if it takes you more time. Thanks for the help
Explanation / Answer
//Program for the above question:(go through the code , if any problem rply us and give ur feedback to //us...thank you)
#include<stdio.h>
#include<math.h>
int main()
{
int choice,num; double radius,volume; float pe,mass,height,acc,velocity,radius1,i;
printf("enter input (1 or 2) : ");
scanf("%d",&choice);
while(!(choice==1||choice==2))
{
printf("wrong input,please re-enter input (1 or 2) ");
scanf("%d",&choice);
}
switch(choice)
{
case 1:
printf("You chose number 1 ");
printf("***MENU*** PLEASE CHOSE THE FOLLOWING OPERATION 1.Volume of sphere for big object 2.Volume for sphere for small object 3.Potential energy for an object(with earth reference) 4.Centripetl acceleration of an object 5.Print a table of curve length for big object with certain increment ");
printf("choose between number 1 to 5 Your choice (1,2,3,4,5):");
scanf("%d",&num);
while(!(num==1||num==2||num==3||num==4||num==5))
{
printf("wrong input,please re-enter input (1 to 5) ");
scanf("%d",&num);
}
switch(num)
{
case 1: printf("you chose to calculate the volume of the big object ");
printf("enter the radius of the object(100m or more):");
scanf("%lf",&radius);
volume=(4/3)*(3.14152)*(pow(radius,3));
printf("volume of the big object ==>%lf",volume);
break;
case 2: printf("you chose to calculate the volume of the small object ");
printf("enter the radius of the object( less than 100m ):");
scanf("%lf",&radius);
volume=(4/3)*(3.14152)*(pow(radius,3));
printf("volume of the small object ==>%lf",volume);
break;
case 3 : printf("you chose to calculate the potential energy of the an object(earth reference) ");
printf("enter the mass and height of the object ");
scanf("%f%f",&mass,&height);
pe=mass*9.8*height;
printf("potential energy of the object ==> %f",pe);
break;
case 4: printf("you chose to calculate the centripetal acceleration of an object ");
printf("enter the velocity and the radius of the object: ") ;
scanf("%f%f",&velocity,&radius1);
acc=pow(velocity,2)/radius1;
printf("the centripetal acceleartion of the object==>%f",acc);
break;
case 5: printf("you chose to print table of curve for big object ");
printf("enter the radius of the object(100m or more):");
scanf("%lf",&radius);
printf("the angles(radians) the curve length in meter 0.00 0.00 ");
for(i=0.12;i<=1.51;)
{
printf("%f %lf ",i,i*radius);
if(i<0.38)
i=i+0.13;
else if(i<0.62&&i>=0.38)
i=i+0.12;
else if(i<0.88&&i>=0.62)
i=i+0.13;
else if(i<1.12&&i>=0.88)
i=i+0.12;
else if(i<1.38&&i>=1.12)
i=i+0.13;
else if(i>=1.38)
i=i+0.12;
//printf("i==%f ",i);
}
break;
default:break;
}
break;
case 2:
printf("you chose number 2 ");
printf("welcome to the end of the program ");
break;
default:break;
}
return 1;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.