-moz-user-select:none; -webkit-user-select:none; -khtml-user-select:none; -ms-user-select:none; user-select:none;

Tuesday, 14 April 2015

Calculating the area and circumference by "switch" statement

Hello and Asalam o Alikum. I hope you all are fine and enjoying good health by the grace of Allah Almighty.Today I am here with another example of "switch" statement.

Explanation

 In this program, I will take radius as input from the user.
In the next step, there would be 2 options before the user. If the user enters "1", then it will calculate the area of the circle by the following formula,

Area=3.1416*radius*radius


If the user enters "2", then it will calculate the circumference of the circle by the following formula,

Circumference=2*3.1416*radius 


If the user enters any other number except "1" and "2", it will display a message,"Invalid operator".

So,below is the source code of this interesting program.

Source code


Output



No comments:

Post a Comment