C Exercises: Find eligibility for admission using Nested If Statement
10. Admission Eligibility Check
Write a C program to determine eligibility for admission to a professional course based on the following criteria:    
  Marks in Maths >=65
Marks in Phy >=55
Marks in Chem>=50
Total in all three subject >=190
or
Total in Math and Physics >=140
Sample Solution:
C Code:
#include <stdio.h>   // Include the standard input/output header file.
void main()
{
    int p, c, m, t, mp;   // Declare variables to store marks and totals.
    printf("Eligibility Criteria :\n");   // Display eligibility criteria.
    printf("Marks in Maths >=65\n");
    printf("and Marks in Phy >=55\n");
    printf("and Marks in Chem>=50\n");
    printf("and Total in all three subject >=190\n");
    printf("or Total in Maths and Physics >=140\n");
    printf("-------------------------------------\n");
    printf("Input the marks obtained in Physics :");   // Prompt user for input.
    scanf("%d", &p);   // Read and store marks in 'p'.
    printf("Input the marks obtained in Chemistry :");
    scanf("%d", &c);   // Read and store marks in 'c'.
    printf("Input the marks obtained in Mathematics :");
    scanf("%d", &m);   // Read and store marks in 'm'.
    printf("Total marks of Maths, Physics and Chemistry : %d\n", m + p + c);   // Calculate and display total marks.
    printf("Total marks of Maths and Physics : %d\n", m + p);   // Calculate and display total marks.
    if (m >= 65)   // Check if marks in Maths are greater than or equal to 65.
        if (p >= 55)   // Check if marks in Physics are greater than or equal to 55.
            if (c >= 50)   // Check if marks in Chemistry are greater than or equal to 50.
                if ((m + p + c) >= 190 || (m + p) >= 140)   // Check if total marks criteria are met.
                    printf("The candidate is eligible for admission.\n");   // Print eligibility message.
                else
                    printf("The candidate is not eligible.\n");   // Print ineligibility message.
            else
                printf("The candidate is not eligible.\n");   // Print ineligibility message.
        else
            printf("The candidate is not eligible.\n");   // Print ineligibility message.
    else
        printf("The candidate is not eligible.\n");   // Print ineligibility message.
}
Output:
Eligibility Criteria : Marks in Maths >=65 and Marks in Phy >=55 and Marks in Chem>=50 and Total in all three subject >=190 or Total in Maths and Physics >=140 ------------------------------------- Input the marks obtained in Physics :65 Input the marks obtained in Chemistry :51 Input the marks obtained in Mathematics :72 Total marks of Maths, Physics and Chemistry : 188 Total marks of Maths and Physics : 137 The candidate is not eligible.
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to check admission eligibility based on subject marks and additional bonus criteria.
- Write a C program to determine eligibility for a professional course by computing weighted averages of marks.
- Write a C program to assess admission eligibility with detailed error messages for each failing criterion.
- Write a C program to validate subject marks and determine eligibility while using functions for modularity.
Go to:
PREV : Coordinate Quadrant Identification.
NEXT : Quadratic Equation Roots.
C Programming Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
