### 1. Write a C program for performing as calculator which allows all Arithmetic Operators with operands from terminal. Few Input and Output sample are given below:

Recommended:

Sample Input: 1 + 4
Sample Output: 5

Sample Input: 8 % 2
Sample Output: 0

Sample Input: 6 / 2
Sample Output: 3

Sample Input: 5 / 2
Sample Output: 2.5

Source code in c:

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,z,x,w,h;
char c;
float y,m=0.0;

printf("\nWelcome To My Calculator\n");
AB:
printf("\nenter to calculate (Ex:2+2)\n");
scanf("%d%c%d",&a,&c,&b);
z=(a+b);
x=(a*b);
w=(a-b);
h=(a%b);
y=(a/b);
m=y;
switch(c)
{
case '+' : printf("%d+%d=%d",a,b,z);
break;
case '-' : printf("%d-%d=%d",a,b,w);
break;
case '*' : printf("%d*%d=%d",a,b,x);
break;
case '/' : printf("%d/%d=%2.3f",a,b,m);
break ;
case '%' : printf("%d %d=%d",a,b,h);
break ;
default : printf("error syntax");
break ;
}
goto AB;
getch();
}

Source Code in C++

#include<iostream>
using namespace std;
int main()
{
int a,b,sum;
char oper;
cout<<"Enter an equation to Perform : "<<endl;
cin>>a;
cin>>oper;
cin>>b;
if(oper=='+')
sum=a+b;
else if(oper=='-')
sum=a-b;
else if(oper=='*')
sum=a*b;
else if(oper=='/')
sum=a/b;
cout<<sum;
}

### 2. Write a C / C++ program for performing all Arithmetic Operation using Arithmetic Operator. The program will take Integer input from terminal as operand.Hints: C= a+b, Here 'a' and 'b' are operand, '=' is assignment operator, and '+' is arithmetic operator.

Source Code in C++

#include<iostream>
using namespace std;
int main()
{
int b,c,d;
cin>>b;
cin>>c;
d=b+c;
cout<<d<<endl;
d=b-c;
cout<<d<<endl;
d=b*c;
cout<<d<<endl;
d=b/c;
cout<<d<<endl;
}