Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- int mode;
- int mark;
- int v1;
- int v2;
- int v3;
- float average;
- int temp;
- int x;
- int y;
- int z;
- int area;
- int oddeven;
- /////////////////////////////////////////// PROGRAM 1
- void prog1() {
- printf("give me a number for x that is larger than 5:\n");
- scanf_s("%d", &x);
- if (x > 0)
- {
- if (x > 5)
- {
- printf("\n that number (%d) was greater than 5, 10 points!!!\n", x);
- }
- else
- {
- if (x == 5)
- {
- printf("I said GREATER than 5\n");
- }
- else
- {
- printf("That number (%d) was smaller than 5, good job\n", x);
- }
- }
- }
- else
- {
- printf("\ni said give me a number you retard\n");
- }
- }
- ////////////////////////////////Program 2
- void prog2()
- {
- printf("\n what percentage mark did you get?");
- scanf_s("%d", &mark);
- if (mark > 60)
- {
- printf("\nwell done you got a distinction");
- }
- else
- {
- printf("\nyou got less than distinction");
- }
- }
- ///////////////////////////Program 3
- void prog3()
- {
- printf("\n\n\n\nplease type in 3 numbers, pressing enter inebtween numbers:\n");
- scanf_s("%d", &v1);
- scanf_s("%d", &v2);
- scanf_s("%d", &v3);
- average = (v1 + v2 + v3) / 3.0f;
- printf("\n\nThe average of the numbers you entered is: %f", average);
- }
- ///////////////////////////PROGRAM 4
- void prog4()
- {
- printf("Give me a number, and i will tell you if it is odd or even!!\n");
- scanf_s("%d", &oddeven);
- temp = oddeven % 2;
- printf("DEBUG: temp variable: %d\n", temp);
- if (oddeven % 2)
- {
- printf("The number is odd\n");
- }
- else
- {
- printf("the number is even\n");
- }
- }
- //////////////////////////MAIN
- void main(){
- printf("\n\nHi!\n\nWelcome to the menu\n");
- printf("1. For the greater than 5 test, type '1'\n");
- printf("2. For AND test, type '2'\n");
- printf("3. For AVERAGE calculator press 3\n");
- printf("4. For ODD/EVEN check\n");
- printf("\n\n\nType 0 to quit");
- scanf_s("%d", &mode);
- switch (mode)
- {
- case 0:
- exit(0);
- break;
- case 1:
- prog1();
- break;
- case 2:
- prog2();
- break;
- case 3:
- prog3();
- break;
- case 4:
- prog4();
- break;
- default:
- printf("\n\n\nERROR, that is not an option!!!");
- break;
- }
- getch();
- main();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement