Computer Science, asked by BIGBOSS2002, 16 hours ago

WAP in C to accept 5 no. in an array & ask a no. to search & check if it is present or not.

Answers

Answered by kundankar2002
1

Answer:

#include<stdio.h>

int main()

{

int i,arr[5],sn,p=0;

for(i=0;i<5;i++)

{

printf("Enter a number:- ");

scanf("%d",&arr[i]);

}

printf("Enter a number to Searche:- ");

scanf("%d",&sn);

for(i=0;i<5;i++)

{

if(arr[i]==sn)

{

p=1;

break;

}

}

if(p==0)

printf("Number not found");

else

printf("Number found");

return 0;

}

CASE 1:-

Enter a number:- 1

Enter a number:- 2

Enter a number:- 3

Enter a number:- 4

Enter a number:- 5

Enter a number to Searche:- 3

Number found

CASE 2:-

Enter a number:- 1

Enter a number:- 2

Enter a number:- 3

Enter a number:- 4

Enter a number:- 5

Enter a number to Searche:- 7

Number not found

Similar questions