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; }
Comments
Leave a comment