Mr. Karan buys a lottery ticket. There are 5 numbers that are selected as winners in 5 regions. Check whether Mr. Karan won the lottery or not.
Requirements:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
int i, j;
int lottery_numbers[5];
int karan_num;
for (i = 0; i < 5; i++)
{
printf("enter lottery number of region %d: ", i + 1);
scanf("%d", &lottery_numbers[i]);
}
printf("enter lottery number of Mr. Karan: ");
scanf("%d", &karan_num);
j = -1;
for (i = 0; i < 5; i++)
{
if (lottery_numbers[i] == karan_num)
j = i;
}
if (j >= 0)
printf("Mr. Karan won the lottery\n");
else
printf("Mr. Karan did not win the lottery\n");
return 0;
}
Comments
Leave a comment