Lab Manual PPS

Program to receive marks of physics, chemistry & maths from user & check its eligibility for course.

Write a Program to receive marks of physics, chemistry & math’s from user & check its
eligibility for 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

Code

#include <stdio.h>

int main()
{
    float ph, ch, ma;
    printf("Enter marks of physics");
    scanf("%f", &ph);
    printf("Enter marks of chemistry");
    scanf("%f", &ch);
    printf("Enter marks of maths");
    scanf("%f", &ma);
    //printf("%.2f, %.2f, %.2f", ph, ch, ma);
    if(ph>40&&ch>50&&ma>60)
    {
        if((ph + ch >150)||(ph+ch+ma>200))
        {
            printf("you are eligible.");
        }
        else
        {
            printf("you are not eligible..");
        }
    }
    else
    {
        printf("you are not eligible...Sorry");
    }

    return 0;
}

Description

This is a C program that asks the user to input their marks in Physics, Chemistry, and Maths and then checks whether they are eligible for admission based on certain criteria. Here’s a step-by-step explanation of the code:

<studio.h> This is a header file that includes standard input and output functions for reading and writing data to the console.

The main() function is the entry point of the program. It declares three floating-point variables ph, ch, and ma to store the marks obtained in Physics, Chemistry, and Maths, respectively.

These printf() and scanf() functions prompt the user to enter the marks obtained in each subject and store them in the respective variables.

if(ph>40&&ch>50&&ma>60) This is a conditional statement that checks if the marks in each subject meet the minimum eligibility criteria.

If the eligibility criteria are met, the program checks if the candidate’s total marks in Physics and Chemistry or all three subjects meet the required minimum marks. If they do, it prints “you are eligible.” Otherwise, it prints “you are not eligible.”

In Case eligibility criteria doesn’t match, the program prints “you are not eligible…Sorry”.

return 0; This line signals the end of the main function and returns a value of 0 to indicate successful execution of the program.

Output

Enter the marks of physics 20
Enter the marks of chemistry 80
Enter the marks of maths 90
you are not eligible...Sorry