TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Linear Search In C Programming
Shobana J
Jul 29, 2016
46.7
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog, you will learn how to find the linear search in C programming.
linear.zip
Introduction
In this blog, I am going to explain how to find the linear search in C programming.
It is used to find whether the given number is present in an array or not. If it has means then it can find the location of an array.
Software Requirements
Turbo C++ or C.
Programming
#include < stdio.h >
int
main()
{
int
array[100], search, c, n;
printf(
"Enter the number of elements in array\n"
);
scanf(
"%d"
, & n);
printf(
"Enter %d integer(s)\n"
, n);
for
(c = 0; c < n; c++) scanf(
"%d"
, & array[c]);
printf(
"Enter the number to search\n"
);
scanf(
"%d"
, & search);
for
(c = 0; c < n; c++) {
if
(array[c] == search) {
printf(
"%d is present at location %d.\n"
, search, c + 1);
break
;
}
}
if
(c == n) printf(
"%d is not present in array.\n"
, search);
return
0;
}
Explanation
It is very simple programming and the linear search is always known as Sequential search. With the help of programming, the linear search of an array can be found.
Output
Linear Search
C
Next Recommended Reading
OOPs Dynamic Binding Program Using C++