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 row-wise 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 Format:
The input consists of three integers, m, n, roll, which corresponds to the number of rows, number of columns and roll number of student, respectively.
Output Format:
The output consists of a string --- “yes” or “no”.
[All text in bold corresponds to the 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
Program Code:
#include<stdio.h>
int main()
{
int r,c,s;
printf("Enter the number of rows\n");
scanf("%d", &r);
printf("Enter the number of columns\n");
scanf("%d", &c);
printf("Enter the roll number of the student\n");
scanf("%d", &s);
if(s%c==0||s%c==1||s<=c)
printf("yes");
else
printf("no");
return 0;
}
Post A Comment:
0 comments: