Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. void PrintMenu(void);
  4. int SelectNo(void);
  5. double Increment(double x1);
  6. int main()
  7. {
  8.     int number;
  9.     double x = 64.0;
  10. do
  11. {
  12.     PrintMenu();
  13.     number = SelectNo();
  14.     switch(number)
  15.     {
  16.     case 1:
  17.         x = Increment(x);
  18.         break;
  19.     case 2:
  20.         printf("The current value of x is %lf\n",x);
  21.         x *= 2;
  22.         printf("The new value of x is %lf\n",x);
  23.         break;
  24.     case 3:
  25.         printf("The current value of x is %lf\n",x);
  26.         x =sqrt(x);
  27.         printf("The new value of x is %lf\n",x);
  28.         break;
  29.     case 4:
  30.         break;
  31.     default:
  32.         printf("Select a number from 1 to 4\n");
  33.         break;
  34.     }
  35. }
  36. while (number != 4);
  37. return 0;
  38. }
  39. void PrintMenu(void)
  40. {
  41.     printf("1.Increment\n");printf("2.Multiply by 2\n");
  42.     printf("3.square root\n");printf("4.Exit\n");
  43. }
  44. int SelectNo(void)
  45. {
  46.     int No;
  47.     printf("Select one of the previous number:");
  48.     scanf("%d",&No);
  49.     return No;
  50. }
  51. double Increment(double x1)
  52. {
  53.     printf("The current value of x is %lf\n",x1);
  54.     ++x1;
  55.     printf("The new value of x is %lf\n",x1);
  56.     return x1;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement