in C languge start with include<stdio.h> int main(){ the output look like: Enter
ID: 3908011 • Letter: I
Question
in C languge start with include<stdio.h> int main(){
the output look like:
Enter Grade 1: 60
Enter Grade 2: 80
Enter Grade 3: 95
Enter Grade 4: 45
Enter Grade 5: 55
Enter Grade 6: 70
Enter Grade 7: 100
Enter Grade 8: 20
Enter Grade 9: 85
Enter Grade 10: 400
The grades array: 60 80 95 45 55 70 100 20 85
The average of all grades: 67.78
The standard deviation of pass grades: 13.76
The fail grades array: 45 55 20
The number of fail grades: 3
Q7.) Programming problem Write a ess than o is entered. Also, the pr rogram that reads grades from the user continuously until a grade greater than 100 or ogram should perform the following tasks 1. Store all grades in 1D array named grades 1 2. Compute and display the average value of all grades. S. Store all passing grades i.e., [60, 100] in an another 1D array named passGradest 1 then compute and display the standard deviation of passing grades. Where, the standard deviation can be computed as: here N is the number of the statistical sample and ? is the mean (average) of atistical sample. the rray named failGradest 1, then re all failing grades i.e., [0, 60) in an another ID a lay all failing grades, and display how many failing grades it has. ut may look like: 1: 60 2.8aExplanation / Answer
#include <stdio.h>
int main(void) {
// your code goes here
int num;
int grades[100];
int passgrades[100];
scanf("%d", &num);
int i=0;
int sum=0;
while(num >= 0 && num <=100)
{
printf("Enter grade %d ",i+1);
scanf("%d", &num);
grades[i]=num;
sum += num;
i++;
}
printf("The grades array: ");
for(int j=0;j<i;j++)
{
printf("%d ",grades[j]);
}printf(" ");
double average = (double)sum/i;
printf("The average of all grades %f ", average);
double sdsum=0;
for(int j=0;j<i;j++)
{ if(grades[j]>=40)
sdsum += ((double)grades[j]-average)*((double)grades[j]-average);
}
printf("Tha standard devaition of pass grades %f ",sqrt(sdsum/i));
printf("The fail grades array: ");
int ct=0;
for(int j=0;j<i;j++)
{
if(grades[j]<40)
{printf("%d ",grades[j]);ct++;}
}
printf(" ");
printf("Number of fail grades: %d",ct);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.