Here we gave easiest understanding program to you.
All programs easy to learn every person.
And all subjects are compulsory in BCA.
Powered by Blogger.

Followers

Tuesday, 17 September 2019

Calculater in c

0 comments

/* C Program to simulate a calculator */


#include<stdio.h> 
int main()
 {
int a,b,c;  
char op;   
printf("Enter an operator");scanf("%c",&op);   printf("Enter 2 values:");   scanf("%d%d",&a,&b);
   switch(op)
   {
case '+':c=a+b;break; case '-':c=a-b;break; case '*':c=a*b;break; case '/':c=a/b;break; case '%':c=a%b;break;
  default :printf("Invalid choice");
     retrun 0;            
   }
printf("Result is %d",c);
   return 0;
 
}
 
 
INPUT/OUTPUT:
 
Enter an operator:*
Enter 2 values:8 9
Result is 72

No comments:

Post a Comment