Question: Intro to C programming question: I have initizalized all my variables but am stuck on using a sentinel value to exit the loop. How would
Intro to C programming question:
I have initizalized all my variables but am stuck on using a sentinel value to exit the loop. How would I write the script so that this program would work?
Program: Partially fill an array with up to 20 students GPAs by prompting the user in a loop. Do the required tasks in given sequence in main() function.
Named Constant: Declare a named constant = 20 for the size of array.
main() Function
1. Declarations:
Declare a float array of size 20 (use the named constant) to store up to 20 GPAs.
Declare other variables as needed.
2. Write a loop to read up to 20 GPAs into the float array. In each cycle of the loop:
Prompt the user to enter a gpa, Use the sentinel value -1 to stop data entry.
Read the entered data into the float array.
If data read is equal to -1, break out of the loop.
3. After the loop, display number of values read into the array.
4. Write another loop to display all the values stored in the array.
5. Compute the average gpa - display it to the screen with 2 digits after the decimal point.
6. Write a loop to add 0.20 to each GPA stored in the array.
If the updated GPA becomes > 4.0, change it to 4.0
7. Write another loop to display all the updated GPAs.
8. Find the maximum GPA display it to the screen.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
