Lecture 37
Conditional Statements (Decision Making)
Code:
//Conditional operators
#include <iostream>
#include <conio.h>
using namespace std;
int main (void)
{
double Sal,Grade,Bonus;
cout<<"Enter your salary: ";
cin>>Sal;
cout<<"Enter your grade: ";
cin>>Grade;
Bonus=((Grade>15)?Sal*50/100:Sal*25/100);
Sal=Sal+Bonus;
cout<<"Your total Salary = "<<Sal;
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10