Seat Allocation I

Seat Allocation I

The seats are arranged in the lab in a rectangular fashion with m rows and n columns. The students are seated in the lab according to their roll numbers in rowwise order, starting from 1.
Given the roll number of a student, find whether the student is seated in the first row or in the 1st or last column.

Input and Output Format:
Refer sample input and output.
The output consists of a string --- “yes” or “no”.

All text in bold corresponds to input and the rest corresponds to output.
Sample Input and Output 1:
Enter the number of rows
5
Enter the number of columns
10
Enter the roll number of the student
41
yes


Sample Input and Output 2:
Enter the number of rows
5
Enter the number of columns
10
Enter the roll number of the student
42
no

Image result for Seat Allocation


#include < stdio.h >
int main()
{
int a,b,c;
printf("Enter the number of rows\n");
scanf("%d",&a);
printf("Enter the number of columns\n");
scanf("%d",&b);
printf("Enter the roll number of the student\n");
scanf("%d",&c);
if(c < =b||c%b==1||c%b==0)
{
printf("yes");
}
else
{
printf("no");
}
return 0;
}

No comments: