Digital जीवन

Free Online Education for India...

Full width home advertisement

Computer Basic

C Programming

Engineering Graphics

Post Page Advertisement [Top]

Dr. A.P.J. Abdul Kalam Technical University, Lucknow

KCS151 / KCS251 Programming for Problem Solving - Using C Language


Lab Exercises


5. Write a program to receive marks of physics, chemistry & maths from user & check its eligibility for the course if
a)  Marks of physics > 40
b)  Marks of chemistry > 50
c)  Marks of math's > 60
d)  Total of physics & math's marks > 150
or
e)  Total of three subjects marks > 200


/*
 File: Prgrm05.c
 Author: Aditya Saini
 Date: Jan 15, 2021
 Description: Program to check eligibility.
*/

#include <stdio.h>

int main (void)
{
     int phy_marks, chem_marks, math_marks;

     //Input marks.
     printf ("Input Marks:\n");
     printf ("Physics: ");
     scanf ("%d", &phy_marks);
     printf ("Chemistry: ");
     scanf ("%d", &chem_marks);
     printf ("Mathematics: ");
     scanf ("%d", &math_marks);

     //Eligibility check
     printf ("(a)  Marks of physics > 40\t\t\t: ");
     if (phy_marks > 40)
          printf ("Pass\n");
     else
          printf ("Fail\n");

     printf ("(b)  Marks of chemistry > 50\t\t\t: ");
     if (chem_marks > 50)
          printf ("Pass\n");
     else
          printf ("Fail\n");

     printf ("(c)  Marks of math's > 60\t\t\t: ");
     if (math_marks > 60)
          printf ("Pass\n");
     else
          printf ("Fail\n");

     printf ("(d)  Total of physics & math's marks > 150\t: ");
     if ((phy_marks + math_marks) > 150)
          printf ("Pass\n");
     else
          printf ("Fail\n");

     printf ("or\n(e)  Total of three subjects marks > 200\t: ");
     if ((phy_marks + chem_marks + math_marks) > 200)
          printf ("Pass\n");
     else
          printf ("Fail\n");

     //Print result
     printf ("Eligible: ");
     if (phy_marks > 40 && chem_marks > 50 && math_marks > 60 &&
          ((phy_marks + math_marks) > 150 || (phy_marks + chem_marks + math_marks) > 200))
          printf ("Yes");
     else
          printf ("No");

     return 0;
};

Output

Input Marks:
Physics: 78
Chemistry: 49
Mathematics: 82
(a)  Marks of physics > 40                               : Pass
(b)  Marks of chemistry > 50                          : Fail
(c)  Marks of math's > 60                                : Pass
(d)  Total of physics & math's marks > 150 : Pass
or
(e)  Total of three subjects marks > 200      : Pass
Eligible: No



No comments:

Post a Comment

Please do not post spam links.

Bottom Ad [Post Page]

| Designed by Colorlib