Pages

This blog is under construction

Sunday, January 6, 2019

Decision-making statements Example:

Program:
Admission to a professional course in subject to the following conditions:
a) Marks in mathematics >=60
b) Marks in Physics >=50
c) Marks in Chemistry >=40
d) Total in all three subjects >=200
or
Total in mathematics and physics>=150.
Given the marks in the three subjects, write a program to process the applications to the eligible candidates.

C Code:

#include<stdio.h>
void main()
{
int Maths,Phy,Chem,Total,Total_MP;
printf("Enter the marks of maths :");
scanf("%d",&Maths);
printf("Enter the marks of phy :");
scanf("%d",&Phy);
printf("Enter the marks of chem :");
scanf("%d",&Chem);
Total=Maths+Phy+Chem;
Total_MP=Phy+Maths;
if (Maths>=60 && Phy>=50 && Chem>=40 && Total>=200)
printf("The candidate is eligible for the admission");
else
{
if(Total_MP>=150)
printf("The candidate is eligible for the admission");
else
 printf("The candidate is not eligible for the admission");
}

}
Output:

Enter the marks of maths :90                                                                                                   
Enter the marks of phy :80                                                                                                     
Enter the marks of chem :20                                                                                                    
The candidate is eligible for the admission




No comments:

Post a Comment