Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.19 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<math.h>
  4. int mode;
  5. int mark;
  6. int v1;
  7. int v2;
  8. int v3;
  9. float average;
  10. int temp;
  11. int x;
  12. int y;
  13. int z;
  14. int area;
  15. int oddeven;
  16. /////////////////////////////////////////// PROGRAM 1
  17. void prog1() {
  18.     printf("give me a number for x that is larger than 5:\n");
  19.     scanf_s("%d", &x);
  20.     if (x > 0)
  21.     {
  22.  
  23.         if (x > 5)
  24.         {
  25.             printf("\n that number (%d) was greater than 5, 10 points!!!\n", x);
  26.         }
  27.         else
  28.         {
  29.             if (x == 5)
  30.             {
  31.                 printf("I said GREATER than 5\n");
  32.             }
  33.             else
  34.             {
  35.                 printf("That number (%d) was smaller than 5, good job\n", x);
  36.             }
  37.         }
  38.     }
  39.     else
  40.     {
  41.         printf("\ni said give me a number you retard\n");
  42.     }
  43. }
  44. ////////////////////////////////Program 2
  45. void prog2()
  46. {
  47.     printf("\n what percentage mark did you get?");
  48.     scanf_s("%d", &mark);
  49.     if (mark > 60)
  50.     {
  51.         printf("\nwell done you got a distinction");
  52.     }
  53.     else
  54.     {
  55.         printf("\nyou got less than distinction");
  56.     }
  57. }
  58. ///////////////////////////Program 3
  59. void prog3()
  60. {
  61.     printf("\n\n\n\nplease type in 3 numbers, pressing enter inebtween numbers:\n");
  62.     scanf_s("%d", &v1);
  63.     scanf_s("%d", &v2);
  64.     scanf_s("%d", &v3);
  65.     average = (v1 + v2 + v3) / 3.0f;
  66.     printf("\n\nThe average of the numbers you entered is: %f", average);
  67. }
  68. ///////////////////////////PROGRAM 4
  69. void prog4()
  70. {
  71.     printf("Give me a number, and i will tell you if it is odd or even!!\n");
  72.     scanf_s("%d", &oddeven);
  73.     temp = oddeven % 2;
  74.     printf("DEBUG: temp variable: %d\n", temp);
  75.     if (oddeven % 2)
  76.     {
  77.         printf("The number is odd\n");
  78.     }
  79.     else
  80.     {
  81.         printf("the number is even\n");
  82.     }
  83. }
  84. //////////////////////////MAIN
  85. void main(){
  86.     printf("\n\nHi!\n\nWelcome to the menu\n");
  87.     printf("1. For the greater than 5 test, type '1'\n");
  88.     printf("2. For AND test, type '2'\n");
  89.     printf("3. For AVERAGE calculator press 3\n");
  90.     printf("4. For ODD/EVEN check\n");
  91.  
  92.     printf("\n\n\nType 0 to quit");
  93.     scanf_s("%d", &mode);
  94.     switch (mode)
  95.     {
  96.     case 0:
  97.         exit(0);
  98.         break;
  99.     case 1:
  100.         prog1();
  101.         break;
  102.     case 2:
  103.         prog2();
  104.         break;
  105.     case 3:
  106.         prog3();
  107.         break;
  108.     case 4:
  109.         prog4();
  110.         break;
  111.     default:
  112.         printf("\n\n\nERROR, that is not an option!!!");
  113.         break;
  114.     }
  115.     getch();
  116.     main();
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement