Hello and Asalam o Alikum. I hope you all are fine by the grace of Allah Almighty.
Today I am here with another interesting program that will convert the height entered in centimeters into inches and feet using "switch" statement.
As I have discussed in my previous blog that a "switch" statement is used to test different conditions.So, below is the explanation of this program.
Today I am here with another interesting program that will convert the height entered in centimeters into inches and feet using "switch" statement.
As I have discussed in my previous blog that a "switch" statement is used to test different conditions.So, below is the explanation of this program.
Explanation
In this program, I will take the height as input from the user.Then, there would be two conditions before the user.If the user enters "1", then it will convert the height into feet by using the formula,
Feet=Height/30.48
If the user enters "2", then it will convert the height into inches by using the formula,
Inches=Height/2.54.
If the user enters any other number except "1" or "2", it will simply display a message, " Invalid choice !".
Below is the source code of this program.
No comments:
Post a Comment