ACCEPT AN OPERATOR AND FIND VALUE
ACCEPT AN OPERATOR AND FIND VALUE
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char z;
int a,b;
printf("enter two
numbers");
cin>>a>>b;
printf(“enter *,-,+,/ only\n
");
cin(“%d”,z);
if(z=='+')
printf("the product is
%d “,a*b);
else if(z=='+')
printf("the sum is
%d",a+b);
else if(z=='-')
printf("the answer is
%d",a-b);
else if(z=='/')
printf("the answer is %d",a/b);
else
printf("\it is not a operator.");
getch();
OUTPUT:
Enter two numbers:
5
6
Enter the operator: +
The sum is 11.
No comments: