Advertisement
prataykumarpaul

Function

Jan 13th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 KB | None | 0 0
  1. #include<stdio.h>
  2. int add (int x, int y)
  3. {
  4.     int result;
  5.     result= x+y;
  6.     printf("Result : %d\n", result);
  7. }
  8.  int sub (int a, int b)
  9. {
  10.     int result;
  11.     result= a-b;
  12.     printf("Result : %d\n", result);
  13. }
  14. float mult (float e, float f)
  15. {
  16.     float result;
  17.    result= (e*f);
  18.     printf("Result : %f\n",result);
  19. }
  20. float div (float j, float k)
  21. {
  22.     float result;
  23.     if(k==0)
  24.         {
  25.              printf("Not Possible \n");
  26.         }
  27.     else
  28.     {
  29.          result= (j/k);
  30.     printf("Result : %f\n", result);
  31.     }
  32. }
  33.  
  34. int main()
  35. {
  36.     printf("(1) Addition\n");
  37.     printf("(2) Subtraction\n");
  38.     printf("(3) Multiplication \n");
  39.     printf("(4) Division\n");
  40.     printf("(5) Delete\n");
  41.     int choice;
  42.     printf("Enter Your choice: \n");
  43.     scanf("%d", &choice);
  44.  
  45.     switch(choice){
  46.     case 1:
  47.          printf("For Addition \n");
  48.         int x, y;
  49.         printf("Enter your numbers: \n");
  50.         scanf("%d %d", &x, &y);
  51.         add(x,y);
  52.         break;
  53.     case 2:
  54.          printf("For Subtraction\n");
  55.         int a, b;
  56.         printf("Enter your numbers: \n");
  57.         scanf("%d %d", &a, &b);
  58.         sub(a,b);
  59.         break;
  60.  
  61.     case 3:
  62.          printf("Fot Multiplication \n");
  63.         float e, f;
  64.         printf("Enter your numbers: \n");
  65.         scanf("%f %f", &e, &f);
  66.         mult(e,f);
  67.         break;
  68.     case 4:
  69.          printf("For Division\n");
  70.         float j, k;
  71.         printf("Enter your numbers: \n");
  72.         scanf("%f %f", &j, &k);
  73.         div(j,k);
  74.         break;
  75.     case 5:
  76.         printf("You Have deleted your program\n");
  77.         break;
  78.  
  79.     default:
  80.         printf("wrong input");
  81.         break;
  82.  
  83.     }
  84.  
  85.     return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement