/* Program: The switch statement */
#include <iostream.h>
#include <conio.h>
void main()
{
int rn;
cout<<"Enter Room number : ";
cin>>rn;
switch (rn)
{
case 1 :
cout<<"Hi! This is Room 1.\n";
break ;
case 2 :
cout<<"Hi! This is Room 2.\n";
break ;
case 3 :
cout<<"Hi! This is Room 3.\n";
break ;
case 4 :
cout<<"Hi! This is Room 4.\n";
break ;
default :
cout<<"Wrong Way !!\n";
}
getch () ;
}
---------------------------------------------
/* Program : The switch statement */
#include <iostream.h>
#include <conio.h>
void main()
{
int p ;
cout<<"Enter any value between 1 to 5 :\n";
cin>>p;
switch (p)
{
case 4 :
cout<<"Welcome to the world of C++!!\n";
break ;
case 5 :
cout<<"This is section two.\n";
break ;
case 3 :
cout<<"This happens to be section three.\n";
break ;
case 1 :
cout<<"Oops! This is section four.\n";
break ;
case 2 :
cout<<"This is the last chance u have...\n";
break ;
default:
cout<<"I am sorry! Wrong Way !!\n";
}
getch () ;
}
-----------------------------------
/* Program : The switch statement */
#include <iostream.h>
void main()
{
char c ;
cout<<"Enter any one character from the word 'worry': ";
cin>>c;
switch (c)
{
case 'W':
case 'w':cout<<"I am in case w\n";
break ;
case 'O':
case 'o':cout<<"I am in case o\n";
break ;
case 'R':
case 'r':cout<<"I am in case r\n";
break ;
case 'Y':
case 'y':cout<<"I am in case y\n";
break ;
default:cout<<"U entered the wrong letter !!\n";
}
}
#include <iostream.h>
#include <conio.h>
void main()
{
int rn;
cout<<"Enter Room number : ";
cin>>rn;
switch (rn)
{
case 1 :
cout<<"Hi! This is Room 1.\n";
break ;
case 2 :
cout<<"Hi! This is Room 2.\n";
break ;
case 3 :
cout<<"Hi! This is Room 3.\n";
break ;
case 4 :
cout<<"Hi! This is Room 4.\n";
break ;
default :
cout<<"Wrong Way !!\n";
}
getch () ;
}
---------------------------------------------
/* Program : The switch statement */
#include <iostream.h>
#include <conio.h>
void main()
{
int p ;
cout<<"Enter any value between 1 to 5 :\n";
cin>>p;
switch (p)
{
case 4 :
cout<<"Welcome to the world of C++!!\n";
break ;
case 5 :
cout<<"This is section two.\n";
break ;
case 3 :
cout<<"This happens to be section three.\n";
break ;
case 1 :
cout<<"Oops! This is section four.\n";
break ;
case 2 :
cout<<"This is the last chance u have...\n";
break ;
default:
cout<<"I am sorry! Wrong Way !!\n";
}
getch () ;
}
-----------------------------------
/* Program : The switch statement */
#include <iostream.h>
void main()
{
char c ;
cout<<"Enter any one character from the word 'worry': ";
cin>>c;
switch (c)
{
case 'W':
case 'w':cout<<"I am in case w\n";
break ;
case 'O':
case 'o':cout<<"I am in case o\n";
break ;
case 'R':
case 'r':cout<<"I am in case r\n";
break ;
case 'Y':
case 'y':cout<<"I am in case y\n";
break ;
default:cout<<"U entered the wrong letter !!\n";
}
}
0 comments:
Post a Comment