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...

  • 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: Round the average...

  • 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...

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

    - 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 has...

  • 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...

  • PHYTHON NOT JAVA!!! need HELP ASAP!!! This program gets a series of test scores and #...

    PHYTHON NOT JAVA!!! need HELP ASAP!!! This program gets a series of test scores and # calculates the average of the scores with the # lowest score dropped. def main(): # Get the test scores from the user and store it in a variable called scores.    # Get the total of the test scores and store it in a variable called total.    # DONE - Get the lowest test score and store it in a variable called lowest....

  • 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 javascript program that asks the user to enter five test scores. The program should...

    Write a javascript 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. Write the following methods in the program: calcAverage—This method should accept five test scores as arguments and return the average of the scores. determineGrade—This method should accept a test score as an argument and return a letter grade for the score,

  • 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...

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