Hi there again i tried answering the question amm i hope you guys can understand it its a structure ahh i am to:

Write a program using (structures) that stores the details of students in a school.
Create a structure called students with the following structure elements: Student name. student number, program name, course, year of joining, engish marks, maths marks, and physics marks.
the program should
1. input all the details for one student
2. the data entered for the marks should not be greater than 100 and less than 0
3. caculate the average of the students.
4. if the average of the student is greater than 75, print the Grade of the student as "First Class".
5. If the average is greater than 50 and less than or equal to 75, print the Grades of the student as "Second Class"
6. If the average of the student is less than or equal to 50, print the grade of the students as "Failed".

finally print student name, student number, year, enlgish marks, maths marks, physics marks and average.

After that i was asked to prompt the user with a choice of weather they would like to continue they are to enter y or n the program should terminate if they enter n. thats it
i hope someone finds the problem thank you

``````#include<stdio.h>

struct students
{
char name[15],p_name[20],course[20];
int st_num,year_join,eng_mark,maths_mark,phy_mark;
};

void main()
{
char choice;
int count=0;
float average;

// user given and prompt by the program to enter data from the keyboard.
struct students student_records;
// struct students is the name given to the structure and student_records-
// is the name for the elements of the structure.
Do
{
scanf("%s",student_records.name);
scanf("%d",&student_records.st_num);
printf("Please enter the year the student started these courses\n");
scanf("%d",student_records.year);
scanf("%d",&student_records.eng_mark);
scanf("%d",&student_records.maths_mark);
scanf("%d",&student_records.phy_mark);
//checking to see if marks entered matches criteria
if((((((student_records.eng_mark<0)||(student_records.eng_mark<100)||(student_records.maths_mark<0)||(student_records.phy_marks>100)
{
printf("One or more of your students marks was either greater than 100 or less than 0, please re-enter these marks. Thanl you\n");
// requesting users input of marks respectively for subjects.
scanf("%d",&student_records.eng_mark);
scanf("%d",&student_records.maths_mark);
scanf("%d",&student_records.phy_mark);
}
//finding the average for all marks entered.
average=(student_records.eng_mark+student_records.maths_mark+phy_mark)/3;
// statements(blocks) used to check for respective average conditions.
if(average >75)
{
printf("You are of \"First Class\"\n");
}
else if(average >50)
{
printf("You are of \"Second Class\"\n");
}
else
//printing information for student

printf("The student name is = %s",student_records.name);
printf("The students number/idno is = %d",student_records.st_num);
printf("The student joined = %d",student_records.year);
printf("The student mark for english is = %d",student_records.eng_mark);
printf("The student mark for mathematics is = %d",student_records.maths_mark);
printf("The student mark for physics is = %d",student_records.phy_mark);
//A statement used to prompt user to continue or not
printf("Would you like to continue entering information for another user type 'y' for yes 'n' for no please note that if you type 'n' the program will terminate\n");
scanf("%c",choice);
count+=1;
}
// statement used to terminate program/to continue it.
while(choice!="n")
getchar():
getchar();
}``````
3
Contributors
5
Replies
6
Views
10 Years
Discussion Span
Last Post by prushik

You have "void main" instead of "int main" on line 9, my compiler complained about the word "Do" on line 19 (should be lowercase - "do"), there is no "year" in your struct in line 26, and why do you have so many parentheses in your if statement in line 34?