Search This Blog

Friday, October 7, 2011

In an examination a student appeared in three subjects. A student may be declared passed if s/he gets 40 or more marks in each subjects and secures a total 150 or more marks in all three subjects. Further, if a student may be declared passed , s/he is awarded a grade A if her/his total marks is 210 or more , grade B if marks is more than 180 otherwise grade C. Write a program to evaluate all thee sub and assing grade and marks.

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:   
   4:  void main()
   5:  {
   6:  int mark1,mark2,mark3,total;
   7:  char result,grade;
   8:  clrscr();
   9:  printf("Enter the marks1,2 and 3:");
  10:  scanf("%d %d %d",&mark1,&mark2,&mark3);
  11:  total=mark1+mark2+mark3;
  12:  /*If mark in each sub is more than 40 and total is 150 or more*/
  13:  if(mark1>=40 && mark2>=40 && mark3>=40 && total>=150)
  14:  result='P';
  15:  else
  16:  result='F';
  17:  /* If passes with 210 or more marks */
  18:  if(result=='P' && total>=210)
  19:  grade='A';
  20:  /* If passes with 180 or more marks */
  21:  if(result=='P' && total>=180)
  22:  grade='B';
  23:  /* If passes with less than 180 marks */
  24:  if(result=='P' && total<180)
  25:  grade='C';
  26:  /*Display the Results */
  27:  if(result=='P' && grade=='A')
  28:  printf("Passed with A grade");
  29:  if(result=='P' && grade=='B')
  30:  printf("Passed with B grade");
  31:  if(result=='P' && grade=='C')
  32:  printf("Passed with C grade");
  33:  if(result=='F')
  34:  printf("Failed");
  35:  getch();
  36:  }

No comments:

Post a Comment