Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement: In a class of 90 students, the score of any student is between 60 and 100 on an exam. It is assumed that

Problem Statement:

In a class of 90 students, the score of any student is between 60 and 100 on

an exam. It is assumed that none of students scored less than 60. Use random number generator

to assign score to each student in class.

Write a c program to perform the following action:

(1) List student score in ascending order and store the respective student number (index);

(2) List the number of students in the ranges: (a) between 60 and 70; (b) between 70 and

80; (c) between 80 and 90; and (d) between 90 and 100;

(3) Compute the average (mean) of student scores on this exam;

(4) Compute the median of student score on this exam;

(5) Compute the standard deviation of student scores on this exam;

Write pseudo code for this problem first;

C program Hints:

1) generate 90 student scores using random number generation

2) Use if construct to test student score in ranges given to get scores in ascending order;

3) Average (Mean) of student scores stored in studscore[] array is given by:

printf(the median of class score is = %f , median);

/* here studscore[ ] array is sorted in ascending order */ (see Previous Program#2)

5) Standard Deviation of student scores in stdscore[ ] array is given by:

C Program pseudo steps for Average done (see HomeWork#2 Revised Program#3)

Continue with Step#4: To determine Median ( we must first order from smallest to largest) See Previous program #2

Median = studscore[size/2]

Step#5: compute Standard Deviation: Use for loop from j=0 to j= size -1

sum = 0; size =90; double deviation=0; double stddeviation=0;

for (int j = 0; j < size; ++j)

{

deviation = studscore[j] average;

sum += deviation*deviation;

}

stddeviation = sqrt(sum/(size-1));

printf(the standard deviation of class scores = %f ,stddeviation);

/* determine the average, median, std dev of class score of 90 students in a class */

{

/* (1) Generate student score between 60 and 100 using rand() function */

/* (2) Store student scores in array named studscore[] array. */

/* Step#1-a) Generate seed value for rand() function using time(NULL) function */

/* C-code for generating seed for random number generator function rand()*/

/* srand() function is called only once in a C program at the top before calling rand() function */

srand( time(NULL) );

/* Step#1-b) Use rand() function to generate 90 random number between 60 and 100 */

/* step#2) and store in array named stdscore[j], with j from j=0 to j < 90 */

/* C-code for generating and storing random numbers in stdscore[] variable */

int j = 0; int studscore[90]; int n = 90; int temp;

for ( int j = 0; j < n; j++) { /* use for loop through n = 90 times the next block of statements */

/* generate random number between 60 and 100 and store it in array[j] */

studscore[j] = (1 + rand() % (100-60) ) +60 ;

}

/* C code to find numbers in array in an ascending order */

/* Take each array element array[j] and compare it with all array element to find the smallest */

/* and switch the smallest element with a[j] */

for (j=0; j < n; j++) {

for (int k=j+1; k < n; k++)

{

if(studscore[j] > studscore[k]) {

temp = studscore[k];

studscore[k] = studscore[j];

studscore[j] = temp;

}

}

}

/* Step#3-a) sum (total) of student scores stored in studscore[] array is given by: */

/* sum = sum of all student score; we use for loop through n = 90 times the block of statements sum = sum +

studscore[j] */

double sum = 0; /* define variable to hold the sum of student score */

for ( int j = 0; j < n; j++) { /* use for loop through n = 90 times the next block of statements */

/* add sum to studscore[j] to get new sum */

sum = sum + studscore[j]; /* this can also be written using += symbol as sum+=studscore[j]; */

}

/* Step#3-b) Compute class average of student scores */

double average=0; double median =0; double stddeviation = 0;

average = sum/n;

/* print the average of student score */

printf("The class average of %d student scores is = %f ", n, average);

/* Step#4) To find the median of class score */

median = studscore[n/2];

printf("The median of class scores is = %f ",median);

/* Step#5: compute Standard Deviation: Use for loop from j=0 to j= n -1 */

sum = 0; double deviation=0;

for (int j = 0; j < n; ++j) {

deviation = (float) studscore[j] - average;

sum += deviation*deviation;

}

stddeviation = sqrt(sum/(n-1));

printf("The standard deviation of class scores = %f ",stddeviation);

return 0;

}

Please include:

1) title comment of what the program does at the very top of program 2) comment to explain each variable used within program unless the name suggests its meaning 3) comment for each for loop or if-else or while construct what the construct does within the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions