How to write a C Program To Search A Number Inside The Array in C Programming Language ?
Solution For C Program :
/*C Program To Search A Number Inside The Array.*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,num,flag=0,arr[5];
printf("Enter 5 numbers for array:=\n");
for(i=0;i<5;i++)
{
scanf("%d",&arr[i]);
}
printf("Enter number u want to search:=");
scanf("%d",&num);
for(i=0;i<5;i++)
{
if(arr[i]==num)
{
printf("number %d do exist in present array",num);
flag=1;
break;
}
}
if(flag==0)
{
printf("number does not exist in the present array");
}
getch();
}
You may also learn these C Program/Code :