Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- void PrintMenu(void);
- int SelectNo(void);
- double Increment(double x1);
- int main()
- {
- int number;
- double x = 64.0;
- do
- {
- PrintMenu();
- number = SelectNo();
- switch(number)
- {
- case 1:
- x = Increment(x);
- break;
- case 2:
- printf("The current value of x is %lf\n",x);
- x *= 2;
- printf("The new value of x is %lf\n",x);
- break;
- case 3:
- printf("The current value of x is %lf\n",x);
- x =sqrt(x);
- printf("The new value of x is %lf\n",x);
- break;
- case 4:
- break;
- default:
- printf("Select a number from 1 to 4\n");
- break;
- }
- }
- while (number != 4);
- return 0;
- }
- void PrintMenu(void)
- {
- printf("1.Increment\n");printf("2.Multiply by 2\n");
- printf("3.square root\n");printf("4.Exit\n");
- }
- int SelectNo(void)
- {
- int No;
- printf("Select one of the previous number:");
- scanf("%d",&No);
- return No;
- }
- double Increment(double x1)
- {
- printf("The current value of x is %lf\n",x1);
- ++x1;
- printf("The new value of x is %lf\n",x1);
- return x1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement