Friday 13 April 2012

Lecture: 36


Lecture 36
Conditional Statements (Decision Making)
Code:
//Conditional operators
#include <iostream>
#include <conio.h>
using namespace std;
int main (void)
{
    int x;
    cout<<"Enter the number less then five : ";
    cin>>x;
    cout<<((x==1)?"One":
           (x==2)?"Two":
           (x==3)?"Three":
           (x==4)?"Four":"Other number");
  getch();
  return 0;
}


Code view in dev compiler:

Compile the program Ctrl+F9

 Run program Ctrl+F10