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;
}

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat