C Program to Check Eligibility of Students for Engineering or Medical Admission

This program is written using Dev C++ version 5, you can use any standard C compiler to compile the following program. To help you understand this program, we have following sections – problem definition, flowchart, program source code and verified output.

In this C program, we want to compute the following.

  1. Students’ total marks
  2. Compute the cutoff marks
  3. Check if the students are eligible for engineering or medical admission
  4. Display ‘P’ for Pass, ‘F’ for Fail, ‘E’ if eligible for engineering, ‘M’ if eligible for medical admission

Problem Definition

This program require some input from the users. The input to the program is student information.

  1. Name
  2. Registration

and students mark in following 6 subjects.

  1. Language 1
  2. Language 2
  3. Mathematics
  4. Physics
  5. Chemistry
  6. Biology

One the program receives the input values, it will compute following output.

  1. Total marks in all subjects
  2. Average marks in all subjects
  3. Engineering cutoff marks (Must be greater than or equal to 220 for eligibility)
  4. Medical cutoff marks (Must be greater than or equal to 230 for eligibility)
  5. Display ‘P’ if student pass in all subjects (All marks greater than 50)
  6. Display ‘F’ if student fail in any subject ( Mark is less than 50)
  7. Display ‘E’ if student passed and eligible for Engineering admission
  8. Display ‘M’ if student passed and eligible for Medical admission

Let us see how these outputs are calculated.

Total Marks = ( Lang1 + Lang2 + Math + Physics + Chemistry + Biology )
Average Marks = ( Lang1 + Lang2 + Math + Physics + Chemistry + Biology )/6
Engineering Cutoff = Math/2 + Physics/4 + Chemistry/4
Medical Cutoff = Math/2 + Biology/4 + Chemistry/4

Flowchart of the Program

Flowchart - Student Eligibility
Flowchart – Student Eligibility

Program Code

/* Program to Compute the marks of student and decide cutoff for Engineering and Medical Cutoff */
/* Program to Compute the marks of student and decide cutoff for Engineering and Medical Cutoff */

#include "stdio.h"
#include "conio.h"
#define N 10

struct student{

    char name[20];
    int regno;
    int lang1;
    int lang2;
    int math;
    int physics;
    int chemistry;
    int biology;
    int total;
    int avg;
    char result;
    int engg_cutoff;
    int med_cutoff;

};

main()

{

    struct student stud[100];

    int i,n;

    printf("ENTER THE NUMBER OF STUDENTS:\n");
    scanf("%d",&n);


/* Input Student Details */

printf("____________________________________________________\n\n");

    printf("Student whose Result is P has Passed the Course\n\n");
    printf("Student whose Result is F has Failed the Course\n\n");
    printf("Student whose Result is E has passed \n");
    printf("and eligible for Engineering admission\n\n");
    printf("Student whose Result is M has passed\n");
    printf("and eligible for Medical admission \n\n");
printf("____________________________________________________\n\n");

    printf("ENTER STUDENT DETAILS:\n");

for(i=0;i<n;i++)
{
    printf("ENTER STUDENT NAME:");
    scanf("%s",&stud[i].name);

    printf("ENTER STUDENT REGISTRATION NUMBER:");
    scanf("%d",&stud[i].regno);

    printf("ENTER FIRST LANGUAGE MARKS:");
    scanf("%d",&stud[i].lang1);

    printf("ENTER SECOND LANGUAGE MARKS:");
    scanf("%d",&stud[i].lang2);

    printf("MATH:");
    scanf("%d",&stud[i].math);

    printf("PHYSICS:");
    scanf("%d",&stud[i].physics);

    printf("CHEMISTRY:");
    scanf("%d",&stud[i].chemistry);

    printf("BIOLOGY:");
    scanf("%d",&stud[i].biology);
}

/* Student Results, Total Marks, Average Marks */

for(i=0;i<n;i++)
{
    if(stud[i].lang1 < 50 || stud[i].lang2 < 50 || stud[i].math < 50 ||     stud[i].physics < 50 ||
    stud[i].chemistry < 50 || stud[i].biology < 50)
{
    stud[i].result = 'F';
}
else
{
    stud[i].result = 'P';
}
}

for(i=0;i<n;i++)
{

    stud[i].total = 0;
    stud[i].avg = 0;
    stud[i].total  = stud[i].lang1 + stud[i].lang2 + stud[i].math + stud    [i].physics + stud[i].chemistry + stud[i].biology;
    stud[i].avg = stud[i].total/6;
}

/* Print Student Information */

printf("_______________________________________________________________________________________\n\n");

    printf("NAME\tREGNO\tLANG-1\tLANG-2\tMATH\tPHY\tCHEM\tBIO\tTOTAL AVG     RESULT\n\n");

printf("________________________________________________________________________________________\n\n");

for(i=0;i<n;i++)
{
    printf("%s\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d
    %c\n\n"
,stud[i].name,stud[i].regno,stud[i].lang1,stud[i].lang2,stud    [i].math,stud[i].physics,stud[i].chemistry,stud[i].biology,stud    [i].total,stud[i].avg,stud[i].result);

}

printf("*****************************************************************************\n\n");

/* Compute Engineering and Medical Cutoff Marks */

for( i=0;i<n;i++)
{
    stud[i].engg_cutoff = (stud[i].math)/2 + (stud[i].physics)/4 + (stud    [i].chemistry)/4; stud[i].med_cutoff = (stud[i].math)/2 + (stud    [i].biology)/4 + (stud[i].chemistry)/4; stud[i].engg_cutoff = stud    [i].engg_cutoff + stud[i].lang1 + stud[i].lang2; stud[i].med_cutoff =     stud[i].med_cutoff + stud[i].lang1 + stud[i].lang2;

if(stud[i].engg_cutoff >= 220 && stud[i].med_cutoff < 230 )
{
    stud[i].result = 'E'; }else if(stud[i].med_cutoff >= 230)
{
    stud[i].result = 'M';
}
}


/* Print Student Results and Eligibility */

    printf("Name\tTotal\tResult\tMedCO\tEngg_CO\n\n");

printf(______________________________________________\n\n");

for(i=0;i<n;i++)

{
    printf("
%s\t%d\t%c\t%d\t%d\n\n",stud[i].name,stud[i].total,stud    [i].result,stud[i].med_cutoff,stud[i].engg_cutoff);
}
getch();
return 0;
}

Output

The initial screen of the program is as follows, make sure that you read the instruction before providing input to the program for correct output.

Inputs - C Program to Check Student Eligibility
Inputs – C Program to Check Student Eligibility

When you provide inputs correctly, you should receive a similar output shown below.

Output - C Program to Check Student Eligibility
Output – C Program to Check Student Eligibility
Advertisements