Advertisement
fahimkamal63

Calculator

Jun 28th, 2019
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. //  Calculator
  2. //  Date : 28.06.19
  3. #include<stdio.h>
  4.  
  5. int main(){
  6.     char ch;
  7.     double a, b;
  8.     printf("Enter operator: (+, -, *, /)");
  9.     scanf("%c", &ch);
  10.     printf("Enter two number : ");
  11.     scanf("%lf %lf", &a, &b);
  12.  
  13.     if(ch == '+') printf("%.2f + %.2f = %.2f", a, b,(a+b));
  14.     else if(ch == '-') printf("%.2f - %.2f = %.2f", a, b,(a-b));
  15.     else if(ch == '*') printf("%.2f * %.2f = %.2f", a, b,(a*b));
  16.     else if(ch == '/') printf("%.2f + %.2f = %.2f", a, b,(a/b));
  17.     else printf("Error!! Operator is not correct.\n");
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement