Conditional Statements (Decision Making)
If else statement:
Code:
#include <iostream>
#include <conio.h>
using namespace std;
main ()
{
float bs,gs,da,hra;
cout<<"Enter the basic salary ";
cin>>bs;
if(bs<1500)
{
hra=bs*10/100;
da=bs*90/100;
}
else
{
hra=500;
da=bs*98/100;
}
gs=bs+hra+da;
cout<<"Gross selery = Rs "<<gs;
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10