This program will use single variable to get all the four arithmetic operations i.e Addition, subtraction, multiplication and division in c++ .
/*
Developed by deepak anand.
For more programs,
visit programming-stuff-4-u.blogspot.in
*/
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,r;
clrscr();
cout<<"Enter the value of a:";
cin>>a;
cout<<"\nEnter the value of b:";
cin>>b;
cout<<"Value of a="<<a<<"\n";
cout<<"Value of b="<<b<<"\n";
//logic part
r=a+b;
cout<<"Sum of a and b="<<r<<"\n";
r=a*b;
cout<<"Multiplication of a and b="<<r<<"\n";
r=a/b;
cout<<"Division of a and b="<<r<<"\n";
r=a-b;
cout<<"Subtraction of a and b="<<r<<"\n";
getch();
}
/*
Developed by deepak anand.
For more programs,
visit programming-stuff-4-u.blogspot.in
*/
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,r;
clrscr();
cout<<"Enter the value of a:";
cin>>a;
cout<<"\nEnter the value of b:";
cin>>b;
cout<<"Value of a="<<a<<"\n";
cout<<"Value of b="<<b<<"\n";
//logic part
r=a+b;
cout<<"Sum of a and b="<<r<<"\n";
r=a*b;
cout<<"Multiplication of a and b="<<r<<"\n";
r=a/b;
cout<<"Division of a and b="<<r<<"\n";
r=a-b;
cout<<"Subtraction of a and b="<<r<<"\n";
getch();
}
No comments:
Post a Comment