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();
}

Recommended Answers

All 5 Replies

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?

line 16 should read:
students student_records;

am using c language and not c++ plus thats how i was thought to write it with void main()
and the struct students student_records;
that just gave me more errors

what should i have if not so many parentheses i mean i was tryna creat a multiple if using or instead of && get it?, ahh but i fixed the problems u suggest other than the void main thing as i said that how i know to write it and thats it with that it doesn't run do u get it to run?

If you are using c and not c++, why dont you post in the c forum instead of the c++ one?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.