akosiraff

Download C Programming Final Exam

Nov 13th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1.  
  2. Download: https://solutionzip.com/downloads/c-programming-final-exam/
  3. 1) Write a macro for each of the following. DO NOT provide a function … I am looking for a macro (see last set of lecture notes).
  4. a) Area of a Circle
  5. b) Area of a Square
  6. c) Area of a Rectangle
  7. d) Area of a Triangle
  8. You can find formulas and detailed explanations at: http://www.mathisfun.com
  9. 2) Write a function which will determine how many words are in a given string. You can assume that one or more
  10. consecutive white spaces is a delimiter between words, and that the string you pass to your function is null terminated.
  11. 3) Write a function that is passed a month, day, and year and will determine if
  12. that date is valid. You can assume each parameter is passed in as an integer.
  13. Remember to check for leap year!
  14. validDate (5, 31, 1961) …. would be valid
  15. validDate (13, 4, 1967) … would be invalid, the month is invalid
  16. 4) Write a function that takes the values of a two-card blackjack HAND as input, and returns the point total of the hand. The value
  17. of the cards ‘2’ through ‘9’ is equal to their face value, the cards ‘T’, ‘K’, ‘Q’, ‘J’ are worth 10 points and the ace (‘A’) is worth 11 points
  18. unless it comes with another ace, then that second ace is worth 1 point. The program should be able to catch incorrect input.
  19. Enter cards: A Q
  20. The score is 21
  21. Enter cards: A A
  22. The score is 12
  23. Enter cards: T 7
  24. The score is 17
  25. Enter cards: A 5
  26. The score is 16
  27. Enter cards: 7 #
  28. *** Would be invalid, # is not a valid card
  29. Enter cards: Z 4
  30. *** Would be invalid, Z is not a valid card
  31. Hint: I’ve used a value of ‘T’ for the 10 card so you can simply pass in two characters,
  32. instead of strings, as parameters to this function.
  33. 5) Write a function to determine is a given word is legal. A word is illegal if it contains no vowels. For this problem,
  34. the letter Y is considered to be a legal vowel. Pass in a word to this function and it will determine if the word is
  35. legal or not. You can make the following assumptions about the word you a passing to this function.
  36. 1) The string being passed is a combination of letters only (no non-letter check needed)
  37. 2) The string being passed is null terminated
  38. 3) Letters may be capital or lower case and it has no effect on whether its a word
  39. Examples:
  40. sch – is illegal, no vowels
  41. apple – legal, contains a vowel
  42. APPle – legal, uppercase letter combinations do not matter
  43. try – legal, no vowel, but contains the letter ‘y’
  44. 6) Write a function that will determine if a given string is a palindrome. DO NOT use the C library function: strrev
  45. A palindrome is a word or sentence that reads the same forward as it does backward.
  46. Examples of word palindromes would be civic or rotor … a word or phase would be:
  47. Never odd or even
  48. A good web site of examples is: http://www.rinkworks.com/words/palindromes.shtml
  49. 7) Write a function that will return in a structure the following characteristics of a given string:
  50. 1) string length (use strlen),
  51. 2) number of upper case characters
  52. 3) number of lower case characters,
  53. 4) number of digits
  54. 5) number of blank spaces
  55. 6) number of non-alphanumeric characters.
  56. 8) Develop a set of function(s) to compute various offensive statistics on baseball. The following information
  57. will be available on each player:
  58. Number of Walks (BB), Strike Outs (SO), Hit by Pitch (HP), Sac Flys (SF), Singles,
  59. Doubles (2B), Triples (3B), and Home Runs (HR) as well as Number of At Bats (AB).
  60. Based on this information, develop a set of functions that will compute the following:
  61. Total Bases, Batting Average, Home Run Ratio, Strike Out Ratio, On Base Percentage, and Slugging Average.
  62. You do not need to be a baseball fan to do this … All the information you need in
  63. terms of the formulas and explanations can be found at:
  64. http://www.baseball-almanac.com/stats.shtml
  65. Note: Number of hits is: singles + doubles + triples + home runs
  66. If you want to test if your functions are working, see compiled stats of the 2014
  67. Boston Red Sox at: http://www.baseball-reference.com/teams/BOS/2014.shtml
  68. Note: All I am looking for here is a set of functions … you do not need to put them into a
  69. program and show me how you call them, i.e., no main function needed.
  70. 9) Most people enjoy watching movies these days, whether its the classics or modern ones.
  71. Develop a set of structures that could be used to model the information about a movie collection.
  72. What type of information would you want to collect and store about a movie? What would be the right
  73. types in C for that information? Define supporting structures as needed and have one final structure type that
  74. is made up of various members (some members may be on some structure type, others may be simple integers,
  75. floats, chars, arrays, etc).
  76. No program is needed although you might want to create a simple main function
  77. and include your structure types just to test that everything compiles.
  78. This question is similar to the final question on the midterm, but you have learned about many different
  79. types since then. Here is a template to use to get started and indicates what I am looking for in your answer.
  80. Use everything you learned this semester, especially types from the last set of lectures notes.
  81. /* add supporting structures – expect many structure types here … date is good example */
  82. struct date
  83. {
  84. int month;
  85. int day;
  86. int year;
  87. };
  88. /* add other supporting structures */
  89. /* Final structure, such as struct movie */
  90. struct movie
  91. {
  92. /* some members may be a structure type themselves, here is an example */
  93. struct date releaseDate; /* the date the movie was released */
  94. /* other members may be ints, floats, doubles, chars, enum, … */
  95. char title [100]; /* the title of the move */
  96. /* add others */
  97. };
  98. int main ( )
  99. {
  100. struct movie myMovie [1000];
  101. /* nothing else needs to be added to main */
  102. return (0);
  103. };
  104.  
  105. Download: https://solutionzip.com/downloads/c-programming-final-exam/
Add Comment
Please, Sign In to add comment