Advertisement
semsem_elazazy

3 practical

Dec 28th, 2021
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.63 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.    int  n,m;
  6.    char c;
  7.    printf("The first number:");
  8.    scanf("%d",&n);
  9.    printf("\nThe second number:");
  10.    scanf("%d",&m);
  11.    printf("\nThe operation:");
  12.    scanf("\n%c",&c);
  13.    if (c=='+')
  14.    {
  15.    int sum=n+m;
  16.    printf("\n %d + %d = %d",n,c,m,sum);
  17.    }
  18.    else if (c=='-')
  19.    {
  20.    int sub=n-m;
  21.    printf("\n %d - %d = %d",n,c,m,sub);
  22.    }
  23.    else if (c=='*')
  24.    {
  25.     int mul=n*m;
  26.    printf("\n %d * %d = %d",n,c,m,mul);
  27.    }
  28.    else if (c=='/')
  29.    {
  30.        float d=n/m;
  31.    printf("\n %d / %d = %d",n,c,m,d);
  32.    }
  33.    else
  34.    printf("invalid operation ");
  35.     return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement