Search array element from array

C Program to search array element from array : -



Program : -


#include<stdio.h>
#include<conio.h>
#include<string.h>
 void main()
 {
    int a[10],i,no,temp=0;
    clrscr();
    puts("Enter the 10 array element :");
    for(i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
    }
    puts("Enter any no. to check :");
    scanf("%d",&no);
    for(i=0;i<10;i++)
    {
        if(no==a[i])
        {
            temp=1;
            puts("The no is exist");
            break;
        }
    }
    if(temp==0)
    {
        puts("The no is not exist");
    }
    getch();
 }



Output 1 : -

Enter the 10 array element : 1 2 3 4 5 6 7 8 9 10
Enter any no. to check : 5
The no is exist


Output 2 : -

Enter the 10 array element : 1 2 3 4 5 6 7 8 9 10
Enter any no. to check : 11
The no is not exist