WAP to insert 5 elements in an array & search an elements taken as input by the user & print the result if it is found OR linear search

#include<stdio.h>
#include<conio.h>
int main()
{ int i;
int num;
int array[5];
int count=0;

    printf("\n Enter the data to be entered in array \n");
    for(i=0;i<5;i++)
    {
    scanf("%d",&array[i]);
}
   
        printf("\n Enter the data to be searched \n");
        scanf("%d",&num);
        for(i=0;i<5;i++)
        {
            if(num==array[i])
            {
            count =1;
            break;
        }
       
        else
        {
            count=0;
        }
       
    }
    if(count==1)
    {
        printf("\n Data found");
    }
    else
   
        if (count ==0)
    {
        printf("\n Data not found");
    }
    getch();
    return 0;
}

Comments

Popular posts from this blog

cpanel exam CPSP Answers

How to install zimbra collaboration suite 8.8.11 on CentOS 7

awstats installation