Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to receive marks in 2 subjects and output whether the student has passed, failed or is allowed to reappear in any subject

Posted By: Reiner Fischer     Category: C Programming     Views: 18872

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:
- He should get 55% or more in A and 45% or more in B.
- If he gets less than 55% in A he should get 55% or more in B.
However, he should get at least 45% in A.
- If he gets less than 45% in B and 65% or more in A he is allowed to reappear in an examination in B to qualify.
- In all other cases he is declared to have failed.
Write a program to receive marks in A and B and output whether the student has passed, failed or is allowed to reappear in B.

Code for Program to receive marks in 2 subjects and output whether the student has passed, failed or is allowed to reappear in any subject in C Programming

     # include<stdio.h>
     void main()
     {
         int a,b;
         clrscr();

         printf("Enter marks for subject A : ");
         scanf("%d",&a);

         printf("Enter marks for subject B : ");
         scanf("%d",&b);

         if(a>=55 && b>=45)
             printf("Result : PASS");
     //    else if(b>=55 && a>=45)elseif((a<55 && a>=45) && b>=55)
             printf("Result : PASS");

         elseif(b<45 && a>=65)
             printf("You can re-appear for subject B");

         else
             printf("Result : FAIL");
         getch();
     }
  
Share: 



Reiner Fischer
Reiner Fischer author of Program to receive marks in 2 subjects and output whether the student has passed, failed or is allowed to reappear in any subject is from Frankfurt, Germany.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
Philo Meena from India Comment on: Dec 08
I want to write a program on the following basis. Can someone help me?

1. Enter the number of courses taken.
2. Enter the total mark obtained in each course.
3. Then the program should print each time the letter grade of corresponding entered mark by the user exactly after the mark is entered. The grading policy should be according to the table below:
Mark Grade
Mark>=80 A
Mark<80,Mark>=70 B
Mark<70,Mark>=60 C
Mark<60,Mark>=50 D
Mark<50 F

4. Then the program will print the number of each letter grade (i.e. 2A, 4B, 1F).
5. At the end the program will print the average of all the marks entered by the user and will print its corresponding letter grade.

View All Comments