Answer to Question #23969 in C++ for Nourh

Question #23969
11. Suppose I have a variable called num whose value has already been set. Write a switch statement that will print "One" if the value of num is 1, "Two" if the value of num is 2, and "Three" if the value of num is 3.
1
Expert's answer
2013-02-08T06:01:01-0500
#include <iostream>
#include <conio.h>


using namespace std;

int main()
{
int number;
cout<<"Enter number (1,2 or 3): ";
cin>>number;
switch(number){
case 1:
cout<<"One";
break;
case 2:
cout<<"Two";
break;
case 3:
cout<<"Three";
break;
}
getch();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS