Lecture 40
Conditional Statements (Decision Making)
Code:
//Conditional operators
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
int num1;
cout<<"Enter a number:
";
cin>>num1;
switch(num1)
{
case 1:
cout<<"One ";
break;
case 2:
cout<<"Two ";
break;
case 3:
cout<<"Three ";
break;
default:
cout<<"Other number ";
}
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10