#include<stdio.h>
#include<conio.h>
void
main()
{
int
arr[10],i,found=0;
int
num,loc;
clrscr();
printf("\n
Enter elemnts in array");
for(i=0;i<10;i++)
{
scanf("%d",&arr[i]);
}
printf("\n
valyes in array:\n");
for(i=0;i<10;i++)
{
printf("%d",arr[i]);
}
printf("\n
enter any number you want to search:");
scanf("%d",&num);
//searching
for(i=0;i<10;i++)
{
if(arr[i]==num)
{
found=1;
loc=i;
break;
}
}
if(found==1)
printf("\n
number fouind at %d position",loc);
else
printf("\n
number not found");
getch();
}
Output:
Enter
elemnts in array1
2
3
4
5
6
7
8
9
0
valyes in array:
1234567890
enter any number you want to search:5
number fouind at 5 position
No comments:
Post a Comment