apr

Simple calculator

apr
Jun 22nd, 2014
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. /*
  4.     I am making a simple calculator
  5. */
  6.  
  7.  
  8. int main(){
  9.     int a , b , c ;
  10.    
  11.     printf("Enter a digit\n");
  12.     scanf("%d",&a);
  13.    
  14.     printf("Enter another digit\n");
  15.     scanf("%d",&b);
  16.    
  17.     c = a+b;
  18.     printf("%d + %d = %d \n",a,b,c);
  19.    
  20.     c = a-b;
  21.     printf("%d - %d = %d \n",a,b,c);
  22.    
  23.     c = a*b;
  24.     printf("%d * %d = %d \n",a,b,c);
  25.    
  26.    
  27.     if(b==0){
  28.             printf("%d / %d = infinity \n",a,b);
  29.     }else{
  30.     c = a/b;
  31.     printf("%d / %d = %d \n",a,b,c);
  32.    
  33.     }
  34.    
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment