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
{
printf("Please enter student's name\n");
scanf("%s",student_records.name);
printf("Please enter student number(id number)\n");
scanf("%d",&student_records.st_num);
printf("Please enter the year the student started these courses\n");
scanf("%d",student_records.year);
printf("Please enter marks received english\n");
scanf("%d",&student_records.eng_mark);
printf("Please enter marks received for mathematics\n");
scanf("%d",&student_records.maths_mark);
printf("Please enter marks received for physics\n");
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.
printf("Please enter marks received english\n");
scanf("%d",&student_records.eng_mark);
printf("Please enter marks received for mathematics\n");
scanf("%d",&student_records.maths_mark);
printf("Please enter marks received for physics\n");
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
printf("You have failed please see your lecturer for more information\n");
//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();
}