Lecture 41
Conditional Statements (Decision Making)
Code:
//Conditional operators
#include <iostream>
#include <conio.h>
using namespace std;
main ()
{
double
Sal,Grade,Bonus;
cout<<"Enter your salary: ";
cin>>Sal;
cout<<"Enter your grade: ";
cin>>Grade;
switch(Grade>15)
{
case 1:
Bonus=Sal*50/100;
break;
default:
Bonus=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