Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - C language program: Write a function that retrieves a given value from an integer array. If found, outputs the position of the value in the array.
C language program: Write a function that retrieves a given value from an integer array. If found, outputs the position of the value in the array.

#include

int main()

{

int test[]={1,2, 3,5,23,43,4,3,5};

int i,n;

printf("Please enter a number: ");

< p> scanf("%d",&n);

for(i=0;i

if(n==test[i] )

printf("The number is at position %d in the array",i);

if(i==sizeof(test))

printf ("There is no input number in the array");

return 0;

}