Search This Blog

Sunday 2 December 2012

What is Switch in C++?

#include<iostream>
using namespace std;

int main()

{
cout<< "Enter 1 or 2 -------> ";
int a; cin>>a;
switch (a)
{
case 1:
cout<<"1 pressed"<<endl;
break;

case 2:
cout<<"2 pressed"<<endl;
break;

}
return 0;
}
//===============================================================================
You may want to see: Calculator using switch statement. Takes Expression as we write on our copy.

1 comment:

  1. Ι am rеallу enjoying the
    theme/desіgn of your ѕite. Do you
    ever гun іnto any web broωsег compatibіlity issues?
    A small number of my blog audiencе hаvе complainеd аbout my
    blog not working cогreсtly in Eхplorеr but looks gгeat in Safari.
    Do you hаve any adνiсe to help fix this issue?



    Тake a looκ at my blog рost; indian handicrafts

    ReplyDelete