C language Modify the getAvg() function to support passing an array by reference. The parameters of this function...

70.2K

Verified Solution

Question

Programming

C language

  1. Modify the getAvg() function to supportpassing an array by reference.
    • The parameters of this function should be pointer to a floatarray, and the size of the array.
    • Returns the average of the array.
  2. Build a function called getScoreFromUser()with the following properties:
    • Asks the user to enter the score
    • scans into a local float variable
    • returns the float value that the user entered.
  3. Build and present a menu to a user like the following andenclose it into a loop that ends when the Quit option is chosen.Insert a line with your favorite character before and afterprinting the menu.

    ***************************
    1. Enter user name.
    2. Enter scores.
    3. Display average score.
    4. Display summary.
    5. Quit
      ***************************
  4. For Option #1, scanf a string, and store it to a username chararray.
  5. For Option #2, do the following :
    • Ask the user how many exams they have and store that value intoan int variable.
    • Use a for loop in combination withgetScoreFromUser() to get the user's scores.

      Hint: Declare a float array of size 20 to storethe user's scores. If the user wants to enter more than the arraysize we declared, display an error, and have the user re-enter thetest count. Some array members will be left un-used which isokay.

      Hint: You can use this inside your for loop:scores_array[i] = getScoreFromUser()
    • Use the getAvg() function to calculate theaverage of all the tests the user entered.
  6. For Option #3, do the following :
    • If the user has already entered test scores, display theaverage of all the test scores.
    • If the user has not yet entered test scores, display an errormessage similar to: \"Please use the menu to enter test scoresfirst.\"
  7. For Option #4, if the user has not yet entered their name andtest scores, display an error message. Otherwise display theaverage, the letter grade of the average, and the user's name.

    Example: \"Hello Charley, your test scores were 70, 75, 80,85, 90, 95. Your average is 82.5 with letter grade: B.\"

    Hint: You can print \"Hello Charley, your test scores were\" first, and then use for loop to print thetest scores, followed by\"Your average is 90.0 with letter grade: A.\"

Answer & Explanation Solved by verified expert
4.5 Ratings (679 Votes)
header filesincludeincludefunction to calculate and return    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students