Can someone help me write this code? I don\'t get how to use astructure. I\'m tr
ID: 3618563 • Letter: C
Question
Can someone help me write this code? I don't get how to use astructure. I'm trying to generate random numbers for the hw1,hw2,quiz1,quiz2,midterm, and final variables. Can someone give mesome hints on what to do? Thanks.#include <stdio.h>
#include <stdlib.h>
// User-defined variables
struct grade {
int student_id;
double hw1;
double hw2;
double quiz1;
double quiz2;
double midterm;
double final;
double overall_grade;
char letter_grade;
};
int
main(void)
{
struct grade sgrade[15];
double average[7];
int i;
int j;
//Prints the top header for the chart
printf(" # HW1 HW2 Quiz1 Quiz2 Midterm Final Total Grade");
for(j=1;j<16;j++)
{
printf(" %d",j);
for(i=0;i<1;i++)
{
hw1 = 50.0+rand() % 50;
}
}
printf(" ");
system("pause");
return(0);
}
Explanation / Answer
please rate - thanks rand() gets you integers--hope this helps #include #include // User-defined variables struct grade { int student_id; int hw1; int hw2; int quiz1; int quiz2; int midterm; int final; double overall_grade; char letter_grade; }; int main(void) { srand(time(0)); struct grade sgrade[15]; double average[7]; int i; int j; //Prints the top header for the chart printf(" # HW1 HW2 Quiz1 Quiz2 Midterm Final Total Grade"); for(j=0;jRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.