Suppose in an exam a teacher needs to assign topics to the “n” students in two sets according to their roll numbers. For this, he has to divide the students in two groups, one containing the even roll
number, other group having odd roll number. Out of 60 students, help the teacher to identify which set (A or B) the particular student will get. Write a program for the same.
For odd roll numbers- Set A
For even roll numbers– Set B
Example: n=2
enter 2 rollnos
1st Rollno: 7
Output: Set A
2nd Rollno: 16
Output: Set B
#include<stdio.h>
int main(){
int n;
printf("Enter the number of students\n");
scanf("%d", &n);
int i;
for(i=1; i<=60; i++){
printf("Enter roll number %d \n", i);
int roll;
scanf("%d", &roll);
if(roll % 2==0){
printf("Output: Set B\n");
}
else{
printf("Output: Set A\n");
}
if(i==n){
break;
}
}
}
Comments
Leave a comment