daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jun 19th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.    char f;
  6.    float a, b, c;
  7.  
  8.    scanf("%f%c%f", &a, &f, &b);
  9.    
  10.    switch(f) {
  11.    case '+':
  12.       c=a+b;      
  13.       break;
  14.    case '-':
  15.       c=a-b;
  16.       break;
  17.    case '*':
  18.       c=a*b;
  19.       break;
  20.    case '/':
  21.       c=a/b;
  22.    default:
  23.       printf("You what?\n");
  24.       return(0);
  25.    }
  26.    
  27.    printf("Your answer is: %f", c);
  28.    return(0);
  29.    
  30. }
  31.  
  32. marc@dhcppc3:~/Documents/c> ./calc
  33. 9
  34. +
  35. You what?
  36. marc@dhcppc3:~/Documents/c>
  37.  
  38. it's a stupid calculator! NOOB
RAW Paste Data
Top