9.16.2011

Find students grades through structure

Q. Write a C program using structure to find student grades in a class. Make necessary assumption.

Ans.
Before writing program we make some assumption as following :

Maximum total marks is 500.     
  Student_percentage         Grades
     >=80                        A
     >=60                        B
     >=50                        C
     >=40                        D
     <40                         F
  
/*C program to find students grades in a class through structure */
#include<stdio.h>
#include<conio.h>
struct stud
{
  char nam[20];
  int obtain_mark;
  int per;
  char grad[5];
};
struct stud s[5];
int i;
int main()
{
 for(i=1; i<=5; i++)
 {
  printf("Enter %d student name : ",i);
  scanf("%s",&s[i].nam);
  printf("Enter %d student obtained marks = ",i);
  scanf("%d",&s[i].obtain_mark);
  fflush(stdin);
 }
 for(i=1; i<=5; i++)
   s[i].per=s[i].obtain_mark/5;
 for(i=1; i<=5; i++)
 {
  if(s[i].per>=80)
    strcpy(s[i].grad,"A");
  else if(s[i].per>=60)
    strcpy(s[i].grad,"B");
  else if(s[i].per>=50)
    strcpy(s[i].grad,"C");
  else if(s[i].per>=40)
    strcpy(s[i].grad,"D");
  else
    strcpy(s[i].grad,"F");
 }
 for(i=1; i<=5; i++)
  printf("\n%d student %s has obtained grade %s ",i,s[i].nam,s[i].grad);
 getch();
 return 0;
}
  Output of above programe :

Enter 1 student name : John
Enter 1 student obtained marks : 250
Enter 2 student name : Robert
Enter 2 student obtained marks : 410
Enter 3 student name : Isabell
Enter 3 student obtained marks : 386
Enter 4 student name : Adem
Enter 4 student obtained marks :197
Enter 5 student name :Harry
Enter 5 student obtained marks : 490 

1 student Jhon has obtained grade C
2 student Robert has obtained grade A
3 student Isabell has obtained grade B
4 student Adem has obtained grade F
5 student Harry has obtained grade A
 


C program for find student grade through structure
Figure: Screen-shot of find student grades 
through structure C program

Related programs:

  1. Get student 5 subject marks and calculate percentage and division

19 comments:

  1. show how to write a program to convert kg to pounds

    ReplyDelete
  2. plz tell how to construct a program o convert wieght from kg to pound where 1 pound=.4536kg

    ReplyDelete
  3. plz tell how to construct a program o convert wieght from kg to pound where 1 pound=.4536kg

    ReplyDelete
  4. plz tell how to construct a program o convert wieght from kg to pound where 1 pound=.4536kg

    ReplyDelete
  5. plz tell how to construct a program o convert wieght from kg to pound where 1 pound=.4536kg

    ReplyDelete
    Replies
    1. I write your C conversion program, with example and how to done the conversion process at:

      http://cprogrammingcodes.blogspot.in/2012/03/kg-to-pound-convert.html

      Delete
  6. you forgot the

    ReplyDelete
  7. you for got the < string . h >

    ReplyDelete
  8. this ish just dont work!!!

    ReplyDelete
    Replies
    1. @Anonyumous(plz login and then comment for easily reply).
      In above program there are not required string header file.
      And all programs in this site work, run and execute in genuine right way.
      (I also mention screen shot of above program).
      Note:what u find error?

      Delete
  9. how i make a flow chat of polynomial multiplied by monomial can u help mee plzzz

    ReplyDelete
  10. how i make a flow chat of polynomial multiplied by monomial can u help mee plzzz

    ReplyDelete
  11. how to make flow chart for this structure programme

    ReplyDelete
  12. create a structure employee and insert the details such as employee id,name,age,employ...
    give the source code of this

    ReplyDelete
  13. plz give me the algorithm&flow chart for this program

    ReplyDelete
  14. Umm Sorry this has no mistake but, after compiling when it's running...
    The result can't be displayed and not responding in Dev C++

    ReplyDelete
  15. please help.. for c program to accept the names and marks of 10 students in 5 subjects. print in descending order the rank list based on the average of the 5 subjects.

    ReplyDelete
  16. please help me in making student and teacher console in c using structures

    ReplyDelete