#include<stdio.h>
int main( )
{
int a[10], i, n, m, c=0 ;
printf("Enter the size of an array : ") ;
scanf("%d", &n) ;
printf("Enter the elements of an array: ") ;
for(i=0;i<=n-1;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the number to be searched: ") ;
scanf("%d",&m) ;
for(i=0;i<=n-1;i++)
{
if(a[i]==m)
{ c=1;
break;
}
}
if(c= =0)
printf("The number is found at %d position",i+1) ;
else
printf("The number is not in an array ") ;
return 0 ;
}
int main( )
{
int a[10], i, n, m, c=0 ;
printf("Enter the size of an array : ") ;
scanf("%d", &n) ;
printf("Enter the elements of an array: ") ;
for(i=0;i<=n-1;i++)
{
scanf("%d",&a[i]);
}
printf("Enter the number to be searched: ") ;
scanf("%d",&m) ;
for(i=0;i<=n-1;i++)
{
if(a[i]==m)
{ c=1;
break;
}
}
if(c= =0)
printf("The number is found at %d position",i+1) ;
else
printf("The number is not in an array ") ;
return 0 ;
}
No comments:
Post a Comment