Lecture 42
Conditional Statements (Decision Making)
Code:
//Conditional operators
#include <iostream>
#include <conio.h>
using namespace std;
main ()
{
int num1;
cout<<"Enter number : ";
cin>>num1;
switch(num1%2 == 0)
{
case 1:
cout
<<"Even number ";
break;
default:
cout
<<"Odd number ";
}
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10