GoogelAddUnit1

Monday, 16 April 2012

WRITE A PROGRAM TO ENTER ANY ARITHEMATIC OPERATOR TO PRINT THE CONCERN RESULT.

AIM:A program to enter any arithematic operator to print the concren result.
PROGRAM:
#include<stdio.h>
main()
{
int a,b;
char op;
printf("enter the values of a,b");
scanf("%d%d",&a,&b);
printf("enter arithematic operator");
scanf("%c",&op);
switch(op)
{
case '+':printf("a+b=%d",a+b);
               break;
case '-':printf("a-b+=%d",a-b);
             break;
case '*':printf("a*b=%d",a*b);
             break;
case '/':printf("a/b=%d",a/b);
             break;
default :printf("unknown arithematic operator");
}
OUTPUT:enter the values of a,b
1,2
enter arithematic operator
'+'
1+2=3.

No comments:

Post a Comment