Question

In: Computer Science

C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate...

C LANGUAGE

Ask user how many scores there are, then ask for each score. Then calculate the average score and scores below 60. Then display the average score and number of scores below 60

Solutions

Expert Solution

Explanation:

Here is the code which asks for the number of scores from the user and then it takes those number of scores from the user and then calculates the sum of the entered scores and also the number of scores below 60.

Then the average and the number of scores below 60 are printed.

Code:


#include <stdio.h>

int main()
{
int scores;
printf("Enter number of scores: ");
scanf("%d", &scores);
  
int scores_below_60 = 0;
int sum = 0;
  
for (int i = 0; i < scores; i++) {
  
int value;
scanf("%d", &value);
sum = sum + value;
  
if(value<60)
scores_below_60++;
}
  
float avg = (float)sum/(float)scores;
  
printf("Average is: %f\n", avg);
printf("Number of scores below 60: %d\n", scores_below_60);

return 0;
}

output:

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!

PLEASE COMMENT IF YOU NEED ANY HELP!


Related Solutions

Create a C++ program that will ask the user for how many test scores will be...
Create a C++ program that will ask the user for how many test scores will be entered. Setup a while loop with this loop iteration parameter. (no fstream) The data needs to include the student’s first name, student number test score the fields should be displayed with a total width of 15. The prompt should be printed with a header in the file explaining what each is: ex. First Name student number Test Score 1) mike 6456464   98 2) phill...
C++ program that will ask the user for how many test scores will be entered. Setup...
C++ program that will ask the user for how many test scores will be entered. Setup a while loop with this loop iteration parameter. The data will include the student’s first name and midterm score Print out the completed test scores to a file (midTermScores.txt) . Print out list of students names and grades in the print out, a letter grade should replace numeric score using standard grading (a = 90 – 100, b=80-90, c=70-80, d=60-70, f=below 60)
Write a program in Java to: Ask the user how many scores they want to enter...
Write a program in Java to: Ask the user how many scores they want to enter (=> Create an array based the entered size) Ask the user to enter their scores in the quarter (Fill the array with the entered scores(assigned to elements)) ==>> Use a "for" loop Find the greatest score Calculate and show the average Show the final grade based on the average (For example A,B,C ... ) Print the scores (the elements of the array) => Use...
Language C++ Ask the user to enter their weight (in pounds) and their height in inches....
Language C++ Ask the user to enter their weight (in pounds) and their height in inches. Calculate their Body Mass Index (BMI) and tell them whether they are underweight, overweight, or at optimal weight. BMI formula: weight * 703 / (height * height) Optimal weight is a BMI from 19 to 26. Lower is underweight, higher is overweight. Prompts: Enter your weight (in pounds): [possible user input: 144] Enter your height (in inches): [posible user input: 73] Possible Outputs: Your...
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
Using (C programming language) Create a health monitoring program, that will ask user for their name,...
Using (C programming language) Create a health monitoring program, that will ask user for their name, age, gender, weight, height and other health related questions like blood pressure and etc. Based on the provided information, program will tell user BMI, blood pressure numbers if they fall in healthy range or not and etc. Suggestions can be made as what should be calorie intake per day and the amount of exercise based on user input data. User should be able to...
In main, create two FracList objects, ask the user how many elements to allocate for each...
In main, create two FracList objects, ask the user how many elements to allocate for each list, read as many Fraction objects from the keyboard as specified by the user into each (using >> operator). Sort both lists using the sort member function and display them; and then search for a value read from the user in both lists and print the index of the first occurrence or that it could not be found in either list. Swap the two...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
Language C++ Ask the user to enter the name of one primary color (red, blue, yellow)...
Language C++ Ask the user to enter the name of one primary color (red, blue, yellow) and a second primary color that is different from the first. Based on the user's entries, figure out what new color will be made when mixing those two colors. Use the following guide: red and blue make purple blue and yellow make green yellow and red make orange If the user enters anything that is outside one of the above combinations, return an error...
Design a program (in C++)to calculate the stock purchasing and selling transactions. 1. ask the user...
Design a program (in C++)to calculate the stock purchasing and selling transactions. 1. ask the user to enter the name of the stock purchased, the number of share purchased, and the price per share purchased 2. assume the buyer pays 2% of the amount he paid for the stock purchase as broker commission 3. assume that the buyer sold all stocks. Ask the user to enter the price per share sold. 4. assume the buyer will pay another 2% of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT