QUESTION
10 Students have randomly requested to Ms.Alice for subject DS allocated with roll no from 1 to 30 randomly .If Alice want to find roll no:5 belongs to her or not? Help her.
“TESTCASE_1”: “1 2 3 4 15 6 7 8 9 10\n###—###SEPERATOR—###—\nRoll no 5 not belongs to Ms.Alice Class”, “TESTCASE_2”: “8 4 6 2 7 5 1 6 14 12\n###—###SEPERATOR—###—\nRoll no 5 belongs to Ms.Alice Class”, “TESTCASE_3”: “9 2 9 1 10 20 13 14 7 4\n###—###SEPERATOR—###—\nRoll no 5 not belongs to Ms.Alice Class”, “TESTCASE_4”: “10 9 8 16 11 12 7 5 3 2\n###—###SEPERATOR—###—\nRoll no 5 belongs to Ms.Alice Class”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0”}
ANSWER
#include <stdio.h>
int main()
{
int i,flag=0; int a[10],rollno=5;
// clrscr();
for (i=0; i<10; i++)
scanf("%d", &a[i]);
for (i=0; i<10; i++)
{
if(a[i]==rollno)
{
flag=1;
break;
}
}
if(flag==0)
printf("Roll no 5 not belongs to Ms.Alice Class");
else
printf("Roll no 5 belongs to Ms.Alice Class");
return 0;
}