C program to search or find an element in given array elements list.
In this tutorial we will solve a problem that find a number in a array. This program check that the given number is available or not in given array.
Here we will write a c program source code to print or find a number is available or present in array.
This program will accept the range or size of an array that entered by user through the keyboard.
After it we will enter the elements of this array.
Now we will enter a number or element to search.
After these steps compiler check and execute the conditions and print the average of best two test marks.
Now we will enter a number or element to search.
C PROGRAM CODE
#include<stdio.h>
#include<conio.h>
void main()
{
int x,num,search,flag=0;
int array[100];
clrscr();
printf("\n ENTER THE SIZE OF ARRAY:\n ");
scanf("%d",&num);
printf("\n ENTER THE ELEMENTS OF THIS ARRAY:\n ");
for(x=0;x<num;x++)
{
scanf("%d",&array[x]);
}
printf("\n ENTER THE ELEMENT TO BE SEARCHED IN THIS ARRAY:\n ");
scanf("%d",&search);
for(x=0;x<num;x++)
{
if(array[x]==search)
{
flag=1;
}
}
if(flag==1)
{
printf("\n SEARCH IS SUCCESSFUL.....\n ");
}
else
{
printf("\n SEARCH IS NOT SUCCESSFUL......\n ");
}
getch();
}
OUTPUT:
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
Created by-- HARSH CHAUHAN
No comments:
Post a Comment