Lecture 32
Conditional Statements (Decision Making)
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (void)
{
int num;
cout<<"Enter a number 1 to 5 : ";
cin>>num;
if (num < 1)
cout <<"Your number less then one ";
else if (num == 1)
cout <<"Your number is \" One \" ";
else if (num == 2)
cout <<"Your number is \" Two \" ";
else if (num == 3)
cout <<"Your number is \" Three \" ";
else if (num == 4)
cout <<"Your number is \" Four \" ";
else if (num == 5)
cout <<"Your number is \" Five \" ";
else
cout <<"Your number large of five ";
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10