Sunday, August 31, 2014

Write a program to receive marks in subject A and B and Output whether the student has passed, failed or is allowed to reappear in B.

Description: A university has the following rules for a student to qualify for a degree with A as the
main subject and B as the subsidiary subject:
  1. He should get 55 percent or more in A and 45 percent or more in B.
  2. If he gets than 55 percent in A he should get 55 percent or more in B. However, he should get at least 45 percent in A.
  3. If he gets less than 45 percent in B and 65 percent or more in A he is allowed to reappear in an examination in B to qualify.
  4. In all other cases he is declared to have failed.

Code

#include<stdio.h>
#include<conio.h>
int main()
{
int pera,perb;

printf("Enter percentage of A and B: ");
scanf("%d%d",&pera,&perb);

if(pera>=55&&perb>=45)
printf("\n Student is passed");

else if(pera>=45&&pera<55&&perb>=55)
printf("\n Student is passed");

else if(perb<45&&pera>=65)
printf("Student is allowed to reappear in an exam");

else
printf("Student is failed");

printf ("\n\nPress any key to close.");

getch ();
return 0;
}

Output

if else in c language

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact