Showing posts with label Switch Statement. Show all posts
Showing posts with label Switch Statement. Show all posts

Friday, 8 August 2014

Write a Program in C++ which Use Switch statement

Structure of the Problem Requirements 


In this problem we learn how to make a Switch statement in C++. Switch statement is use instead of if else condition in programming. If is well organized statement which reduce the complexity of code and increase the readability of your program and code. Just assign the condition input in the switch variable and put their related data in specific case.Here is the Source code of this problem which will help you in better learning . 

Source Code 


#include<iostream>
using namespace std;
int main ()
{
int num=0;
cout<<" Enter Number Between 0-9 \n ";
cin>>num;
switch (num)
{
case 0:
cout<<" You press : " << num;
break;
case 1:
cout<<" You press : " << num;
break;
case 2:
cout<<" You press : "<< num;
break;
case 3:
cout<<" You press : "<< num;
break;
case 4:
cout<<" You press : "<< num;
break;
case 5:
cout<<" You press : "<< num;
break;
case 6:
cout<<" You press : "<< num;
break;
case 7:
cout<<" You press : "<< num;
break;
case 8:
cout<<" You press : "<< num;
break;
case 9:
cout<<" You press : "<< num;
break;
default :
cout<<" You Press Something Else !";
}
}

Output of the Program