Thursday, 10 March 2016

C Program For Find Radius, Circumference and Volume of Cylinder Using Switch Case

Problem:- C Program For Find Radius, Circumference or Circle and Volume of Cylinder Using Switch Case or c program to find volume of cylinder or c program to find circumference of circle or c program to find area of circle or C Program For Find Radius, Circumference and Volume of Cylinder Using Switch Case or C Program For Find Radius, Circumference, and Volume of Cylinder Using Do while loop or C Program For Find Radius, Circumference, and Volume of Cylinder Using loop or C Program For Find Radius, Circumference or Circle and Volume of Cylinder Using do while loop.


Logic:- As we can see that we have to only apply the formula of area of circle or circumference of circle and volume of the cylinder and print the output on the screen, but we also have to put the condition in switch case so that users can easily choose their choice and perform an appropriate operation. In this problem PI value is fixed Pi value up to 10 decimal numbers PI = 3.1415926535. Check The PI Value Up to 1,00,000 Numbers. See the below formulas and explanation of the problem so you can easily understand the problem.

Formula's Are using in problem

1. Area of Circle = PI * Radius * Radius

2. Circumference of Circle = 2 * PI * Radius

3. Volume of Cylinder = PI * Hight * Radius * Radius

Explanation:- In case 1 put the area of circle condition or in case 2 put the second condition Circumference of Circle and last but not least third condition put in case 3 Volume of Circle and now come to special condition case 4 if user want to quite then press 4 this will help to move out the user to loop. In case of the section, there is a special or default case help to check whether the user input the right input or not, if the user enters the input 5 then default case execute and print wrong input try again message on the console screen.

Example:- 

Case 1

Enter Radius = 5
Output = 

Case 2

Enter Radius = 10
Output = 

Case 3 

Enter Radius = 10
Enter Hight = 5
Output = 

Case 0

Output = Exit Program

Case Default:- When user Input another number except 0, 1, 2, 3 or we can say greater than 3.

Output = Wrong Input...Try Again!!!


H/W:- I recommended read this full article, this will help you to build your own logic and solve the problem by using "While" and "For Loop".

Solution:-

#include<stdio.h>
#include<conio.h>

int main()
{

/*visit www.programmingwithbasics.com*/
float radius=0.0,height=0.0;
char quit;
int choice;
const float pi=3.1415658;

do
{
printf("\n=======================================");
printf("\nWhat Do You Want To Calculate?");
printf("\n1. For Area of Circle");
printf("\n2. For Circumference of Circle");
printf("\n3. For Volume of Cylinder");
printf("\n0. For For Quit");
printf("\n=======================================\n");
printf("\nEnter Your Choice Here:");
scanf("%d",&choice);

switch (choice)
{
case 1:
printf("\nEnter Radius of Circle:");
scanf("%f",&radius);
printf("\n=======================================");
    printf("\nArea of Circle = %.5f",radius*radius*pi);
    printf("\n=======================================");
   break;
case 2:
printf("\nEnter Radius of Circle:");
scanf("%f",&radius);
printf("=======================================");
    printf("\nCircumference of Circle = %.5f",2*radius*pi);
printf("\n=======================================");
    break;
case 3:
printf("\nEnter Radius of Cylinder:");
scanf("%f",&radius);
    printf("\nEnter Hight of Cylinder:");
    scanf("%f",&height);
    printf("\n=======================================");
    printf("\nVolume of cylinder = %.5f",radius*radius*pi*height);
    printf("\n=======================================");
    break;
case 0:
    quit='y';
    break;
default:
printf("\n=======================================");
    printf("\nWrong Choice....Try Again!!!\n");
    printf("=======================================");
   break;
}
}while(quit != 'y');

return 0;
}

Output:-


C Program For Find Radius, Circumference and Volume of Cylinder Using Switch Case


You May Also Like:-

1. C Program For Find A Grade Of Given Marks Using Switch Case

2. C++ Program For Store Employee Information And Display Using Structure

3. C Program For Calculator Using Switch Case

4. C++ Program For Bubble Sort

5. Java Program For Find The Gross Salary Of An Employee

6. Hacker Rank Solution For Birthday Cake Candles

7. C++ Program For Selection Sort Using Function

8. Hacker Rank Solution For Strings

9. C Program For Converting Temperature Celsius Into Fahrenheit

10. Hacker Rank solution for 30 Days Of Code



Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment