C Program to search an element in entered array

      No Comments on C Program to search an element in entered array

Search an element in entered array

This program shows the concept to search an element in entered array.The method used in the program is simple search method i.e. comparing each element.

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y[1000],s=0,i,z;
clrscr();
printf("Enter Size of array:-\n");
scanf("%d",&x);
printf("Enter Elements in array:-\n");
for(i=0;i<x;i++)
 {
  scanf("%d",&y[i]);
 }
printf("Eneter Element You Want to Search:-\n");
scanf("%d",&z);
for(i=0;i<x;i++)
 {
  if(z==y[i])
   {
     s=1;
    printf("Element is at location:- %d",i+1);
   }

 }
 if(s==0)
   {
    printf("Element is not found");
   }
 getch();
}

OUTPUT:-

search an element in entered array


Comment below if you are facing any problem.


Also read

Defining array in c lanaguage
C program to enter elements in array of your choice
C Program to find Greatest Element in entered array


Summary
C Program to search an element in entered array
Article Name
C Program to search an element in entered array
Description
This program shows the concept to Search an element in entered array.The method used in the program is simple search method i.e. comparing each element.
Author
Publisher Name
Scanfcode
Publisher Logo

Leave a Reply

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