Lab Allocation II - Practice



Lab Allocation II

There are 3 labs in the CSE department(L1, L2 and L3) with a seating capacity of x, y and z. One of the 3 labs has been allocated for ACE training. Out of the available labs, find the lab which has the minimal seating capacity.

Image result for c programming

Input and Output Format:
Assume that x, y and z are always distinct.
Refer sample input and output.

All text in bold corresponds to input and the rest corresponds to output.
Sample Input and Output 1:
Enter x
30
Enter y
40
Enter z
20
Enter the lab allocated for ACE training
L3
L1 has the minimal seating capacity

#include < stdio.h >
#include < string.h >
int main()
{
int x,y,z;
char a[20];
printf("Enter x\n");
scanf("%d",&x);
printf("Enter y\n");
scanf("%d",&y);
printf("Enter z\n");
scanf("%d",&z);
printf("Enter the lab allocated for ACE training\n");
scanf("%s",a);
if(!strcmp(a,"L1"))
{
if(y < z)
{
printf("L2 has the minimal seating capacity");
}
else
{
printf("L3 has the minimal seating capacity");
}
}
else if(!strcmp(a,"L2"))
{
if(x < z)
{
printf("L1 has the minimal seating capacity");
}
else
{
printf("L3 has the minimal seating capacity");
}
}
else if(!strcmp(a,"L3"))
{
if(x < y)
{
printf("L1 has the minimal seating capacity");
}
else
{
printf("L2 has the minimal seating capacity");
}
}
return 0;
}

No comments: