By 25/02/2014 17 Comments

Example Program for Switch Statement in C++

This is an example program for understanding switch statement in C++.

#include <iostream.h>
#include <conio.h>

void main()
{
     int a, b;
     char ch;

     cout<<"Enter first number: ";
     cin>>a;

     cout<<"Enter second number: ";
     cin>>b;

     cout<<"Enter the operator: ";
     ch=getche();
     cout<<endl;

     switch(ch)
     {
     case '+':
     cout<<"a + b = "<<a+b;
     break;

     case '-':
     cout<<"a - b = "<<a-b;
     break;

     case '*':
     cout<<"a * b = "<<a*b;
     break;

     case '/':
     cout<<"a / b = "<<a/b;
     break;

     default:
     cout<<"You have entered the wrong operator";
     }

   getch();
}






Posted in: C++ Basics

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .