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.
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,
If the user enters "2", then it will calculate the circumference of the circle by the following formula,
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.
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.
No comments:
Post a Comment