Tuesday, March 13, 2012

Program using Switch Statement

/*************<soeasyprograms.blogspot.in>************/
#include<iostream.h>
#include<conio.h>
// Program using Switch Statement
int main()
{
  int input;
 
  cout<<"1. Push\n";
  cout<<"2. Pop\n";
  cout<<"3. Peep\n";
  cout<<"4. Exit\n";
  cout<<"Selection: ";
  cin>> input;
  switch ( input ) {
  case 1:            // Note the colon, not a semicolon
    cout<<"push is called";
    break;
  case 2:            // Note the colon, not a semicolon
    cout<<"pop is called";
    break;
  case 3:            // Note the colon, not a semicolon
    cout<<"peep is called";
    break;
  case 4:            // Note the colon, not a semicolon
    cout<<"Thank you for using stack!\n";
    break;
  default:            // Note the colon, not a semicolon
    cout<<"Error, bad input, quitting\n";
    break;
  }
 
}
/*************<soeasyprograms.blogspot.in>************/

No comments:

Post a Comment