There are 3 labs in the CSE department(L1, L2, and L3) with a seating capacity of x, y, and z. A single lab needs to be allocated to a class of 'n' students. How many of the 3 labs can accommodate 'n' students?
Input and Output Format:
Refer sample input and output.
All text in bold corresponds to the input and the rest corresponds to output.
Sample Input and Output 1:
Enter x
30
Enter y
40
Enter z
20
Enter n
25
2 lab(s) can accommodate 25 students
Sample Input and Output 2:
Enter x
30
Enter y
40
Enter z
20
Enter n
50
None of the labs can accommodate 50 students.
Program Code:
#include<stdio.h>
int main()
{
int x,y,z,n,c=0;
printf("Enter x\n");
scanf("%d", &x);
printf("Enter y\n");
scanf("%d", &y);
printf("Enter z\n");
scanf("%d", &z);
printf("Enter n\n");
scanf("%d", &n);
if(x>=n)
c++;
if(y>=n)
c++;
if(z>=n)
c++;
if(c==0)
printf("None of the labs can accommodate %d students", n);
else
printf("%d lab(s) can accommodate %d students", c, n);
return 0;
}
Post A Comment:
0 comments: