Calculator
Using If-else Statement:
Program
Code;
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{float x,y,z;
int operation;
cout<<"Enter
a Number:";
cin>>x;
cout<<"Enter
another Number:";
cin>>y;
cout<<"Enter
1 for Addition, 2 for Subtraction"<<endl<<" 3 for
Multiplication, 4 for Division ";
cin>>operation;
if (operation ==1)
{cout<<"The
Addition is "<<x+y<<endl;}
else
if(operation == 2)
{cout<<"The
Subtraction is "<<x-y<<endl;}
else
if(operation == 3)
{cout<<"The
Product is "<<x*y<<endl;}
else
{cout<<"The
Division is "<<x/y<<endl;}
getche ();
return 0;
}
0 comments:
Post a Comment