Answer to Question #248011 in C for Sahil

Question #248011

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


1
Expert's answer
2021-10-07T03:57:42-0400
#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;
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS