Could you check this C language Code... The Output is not complete... it doesnt print the firstclas name n id?
my assignment is Write a complete C program that will meet the following requirement:
• Create student detail must contain each student’s name (as a string), id (as integer) and CGPA (double).
• Create 20 students whose names are student1, studnet1, and so on to student20 whose id and status is assigned randomly.
• Find all ‘first class’ student(s) and print their name and ID.
# include <stdio.h>
int main (void) {
typedef struct
{
char name[20];
double cgpa;
int id;
} Detail;
//This will create a new type for you to use...just like int or char...
//Then you'll need
int student_number = 2; //so we can count
Detail student_records[2]; //holds the students
int i;
int j; //Both for loops
for(i = 0; i < student_number; i++){
printf("\nEnter Student Name: ");
scanf ("%s", &student_records.name);
printf("Enter UserID : ");
scanf ("%d", &student_records.id);
printf("Enter Student CGPA: ");
scanf ( "%f", &student_records.cgpa);
}
//Then you need to loop through to check the data...
for(j = 0; j < student_number; j++){
//Check for the stuff you wanted
if( student_records.cgpa >= 3.6){
printf("The First Class Student Are : %s and his metric id is: %d", &student_records.name, &student_records.id);
}
else{
printf("No one is a first class"); }
}//end for loop
return 0;
}
THANKS IN ADVANCE