Question

Write a program that will ask the user to enter 4 quiz scores. These scores should...

Write a program that will ask the user to enter 4 quiz scores. These scores should be from 0 to 100. Use a procedure and pass by reference to get these scores. Write a function that will find the lowest score. This score will be sent back through the function call. You still need to pass the scores by value to this function. Write a function that will calculate the average score. This value will be sent back to main through the call. Pass the scores and low by value. Now write a procedure that will display the scores, the lowest score and average. This is a procedure and will return nothing to main.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the answer..

CODE:

#include<stdio.h>
void getValues(int *a,int *b, int *c, int *d){
   printf("\nEnter first quiz score: ");
   scanf("%d",a);
   printf("\nEnter second quiz score: ");
   scanf("%d",b);
   printf("\nEnter third quiz score: ");
   scanf("%d",c);
   printf("\nEnter fourth quiz score: ");
   scanf("%d",d);  
}
int getLowest(int a, int b, int c, int d){
   if(a<b && a<c && a<d)
       return a;
   if(b<a && b<c && b<d)
       return b;
   if(c<a && c<b && c<d)
       return c;
   if(d<a && d<b && d<c)
       return d;}
float getAvg(int a,int b,int c, int d) {
   return (float)(a+b+c+d)/4;}
void display(int low, float avg) {
   printf("\nlowest : %d",low);
   printf("\nAverage : %f",avg);   }
int main() {
   int a,b,c,d;
   getValues(&a,&b,&c,&d);
   int low=getLowest(a,b,c,d);
   float avg=getAvg(a,b,c,d);
   display(low,avg);
}

OUTPUT:

CPP CODE:

#include <iostream>
using namespace std;
void getValues(int *a,int *b, int *c, int *d){
   cout<<"\nEnter first quiz score: ";
   cin>>*a;
   cout<<"\nEnter second quiz score: ";
   cin>>*b;
   cout<<"\nEnter third quiz score: ";
   cin>>*c;
   cout<<"\nEnter fourth quiz score: ";
   cin>>*d;   }
int getLowest(int a, int b, int c, int d){
   if(a<b && a<c && a<d)
       return a;
   if(b<a && b<c && b<d)
       return b;
   if(c<a && c<b && c<d)
       return c;
   if(d<a && d<b && d<c)
       return d;}
float getAvg(int a,int b,int c, int d) {
   return (float)(a+b+c+d)/4;}
void display(int low, float avg) {
   cout<<"\nlowest : "<<low;
   cout<<"\nAverage : "<<avg;   }
int main() {
   int a,b,c,d;
   getValues(&a,&b,&c,&d);
   int low=getLowest(a,b,c,d);
   float avg=getAvg(a,b,c,d);
   display(low,avg);}

OUTPUT:

If you have any doubts please COMMENT..

If you understand the answer please give THUMBS UP....

Add a comment
Know the answer?
Add Answer to:
Write a program that will ask the user to enter 4 quiz scores. These scores should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program that asks the user to type in their three quiz scores (scores...

    Write a Python program that asks the user to type in their three quiz scores (scores between 0 and 100) and displays two averages. The program should be written so one function gets the user to input a score, another function takes the three scores and returns the average of them. And another function takes the three scores and averages the two highest scores (in other words, drops the lowest). Each of these functions should do the computation and return...

  • Question: - write a C++ program that asks user to enter students' quiz scores, calculate the...

    Question: - write a C++ program that asks user to enter students' quiz scores, calculate the total score for each students and average for all. Note: - number of students: 1 through 5. That is, at least one student and up to 5. - number of quizes: 8 through 10. That is, at least 8 quizes and up to 10. - quiz score range: 0 through 100. - when entering quiz scores, if user enters -1, that means the user...

  • You are to write a program IN C++ that asks the user to enter an item's...

    You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...

  • Write a program that asks the user to enter five test scores. The program should display...

    Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale: Score Letter Grade...

  • Write a console-based program ( C # ) that asks a user to enter a number...

    Write a console-based program ( C # ) that asks a user to enter a number between 1 and 10. Check if the number is between the range and if not ask the user to enter again or quit. Store the values entered in an array. Write two methods. Method1 called displayByVal should have a parameter defined where you pass the value of an array element into the method and display it. Method2 called displayByRef should have a parameter defined...

  • Write a program that will do the following. The main function should ask the user how...

    Write a program that will do the following. The main function should ask the user how many numbers it will read in. It will then create an array of that size. Next, it will call a function that will read in the numbers and fill the array (fillArray). Pass the array that was made in themain function as a parameter to this function. Use a loop that will read numbers from the keyboard and store them in the array. This...

  • Write a program that allows the user to enter a series of exam scores. The number...

    Write a program that allows the user to enter a series of exam scores. The number of scores the user can enter is not fixed; they can enter any number of scores they want. The exam scores can be either integers or floats. Then, once the user has entered all the scores they want, your program will calculate and print the average of those scores. After printing the average, the program should terminate. You need to use a while loop...

  • I need help with this c++ question please thank you ltls. The program should urt valte....

    I need help with this c++ question please thank you ltls. The program should urt valte. 11. Lowest Score Drop Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getscore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of...

  • Write a program that dynamically allocates an integer array of size of 20 to hold a...

    Write a program that dynamically allocates an integer array of size of 20 to hold a user-defined number of test scores. Once all the scores are entered, the array should be passed to • a function that calculates the average score, the minimal score, and the maximal score in the array, and returns these scores to the main function (hint: use pass by reference, I gave an example in the class) • a function that searches a specific number. The...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT