Lecture 33
Conditional Statements (Decision Making)
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main (int argc, char *argv[])
{
char ch;
int num1, num2;
cout<<"Enter number one : ";
cin>>num1;
cout<<"Enter number two : ";
cin>>num2;
cout<<"Are you addition or subtract Or Multiple in between two number \n "
<<"Please Enter (+ Or - Or *) : ";
cin>>ch;
if (ch == '+') cout <<"Addition : " << num1+num2;
else if (ch == '-') cout <<"Subtraction : "<< num1-num2;
else if (ch == '*') cout <<"Multiple : "<< num1*num2;
getch();
return 0;
}
Code view in dev compiler:
Compile the program Ctrl+F9
Run program Ctrl+F10