Advertisement
mejpark

Multiple C programming exercises in a single project

Nov 16th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.54 KB | None | 0 0
  1. /*
  2.  ============================================================================
  3.  Name        : main.c
  4.  Author      : Michael Park
  5.  Version     : 1.0
  6.  Copyright   : Copyright Notice Here (2013)
  7.  Description : Multiple C programming exercises in a single project
  8.  ============================================================================
  9.  */
  10.  
  11. #include <stdio.h>
  12.  
  13. void hello()
  14. {
  15.     puts("Hello, World!");
  16. }
  17. void ex1()
  18. {
  19.     puts("Run exercise 1");
  20. }
  21. void ex2()
  22. {
  23.     puts("Run exercise 2");
  24. }
  25. void ex3()
  26. {
  27.     puts("Run exercise 3");
  28. }
  29. void ex4()
  30. {
  31.     puts("Run exercise 4");
  32. }
  33. void ex5()
  34. {
  35.     puts("Run exercise 5");
  36. }
  37. void ex6()
  38. {
  39.     puts("Run exercise 6");
  40. }
  41. void ex7()
  42. {
  43.     puts("Run exercise 7");
  44. }
  45. void ex8()
  46. {
  47.     puts("Run exercise 8");
  48. }
  49.  
  50. int main()
  51. {
  52.     int choice;
  53.  
  54.     puts( "Choose an exercise between 0 and 8 (0 is Hello, World!):" );
  55.     scanf( "%d", &choice );
  56.     switch ( choice ) {
  57.         case 0:
  58.             hello();
  59.             break;
  60.         case 1:
  61.             ex1();
  62.             break;
  63.         case 2:
  64.             ex2();
  65.             break;
  66.         case 3:
  67.             ex3();
  68.             break;
  69.         case 4:
  70.             ex4();
  71.             break;
  72.         case 5:
  73.             ex5();
  74.             break;
  75.         case 6:
  76.             ex6();
  77.             break;
  78.         case 7:
  79.             ex7();
  80.             break;
  81.         case 8:
  82.             ex8();
  83.             break;
  84.         default:
  85.             puts( "Please enter a number between 0 and 8!" );
  86.             break;
  87.     }
  88.     getchar();
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement