Lecture 43
Conditional Statements (Decision Making)
Code:
//Conditional operators
#include <iostream>
#include <conio.h>
using namespace std;
main ()
{
int Marks;
cout<<"Enter Marks : ";
cin>>Marks;
switch(Marks>40)
{
case 1:
cout<<"Congratulations!
You passed! ";
break;
default:
cout<<"Sorry! You failed! ";
}
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10