Lecture 39
Conditional Statements (Decision Making)
Code:
//Conditional operators
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
float bs,gs,da,hra;
cout<<"Enter the basic salary ";
cin>>bs;
(bs<1500)?
((hra=bs*10/100),(da=bs*90/100)):
((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