F How to find a value postion in array in C program? | CodeTheta

How to find a value postion in array in C program?

January 17, 2014


/* http://native-code.blogspot.com */

#include<stdio.h>
#include<conio.h>
void main()
{
int arr[10];
int i,n;
int f=0;
printf(" /* http://native-code.blogspot.com */    \n\nplease enter range: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
 scanf("%d",&arr[i]);


}
for(i=0;i<n;i++)
{
printf(" /* http://native-code.blogspot.com */    \n\n you entered .. %d",arr[i]);

}

int s;
printf(" /* http://native-code.blogspot.com */    \n\n please neter search value: ");
scanf("%d",&s);
for(i=0;i<n;i++)
{

 if(arr[i]==s)
 {
  printf("\n search is finised element %d found at %d position",s,i);
  f=90;

  break;

 }

}
if(f==0)
{

printf("\n search is unsucessful");
}

getch();
}
/* http://native-code.blogspot.com */

Post a Comment