C Program to Search an Element in an Array2 min read

In this tutorial, we will write a program to search an element in an array in C. There are various ways or algorithm to search an element in an array, we will use linear search.

Before going further, you should have the knowledge of the following topics in C programming.


We will create a program that will take an array element from the user. Then the user will enter an element that needed to be searched. Then the searching will be applied (shown in the program below).

If the element is present in an array it will display found else display not found.

C Program to Search an Element in an Array


C Program to search an element in an array using Pointers

A separate function( search_function()) will be created where the array pointer will be declared and the searched element along with size of an array will be passed. The function will return 1 if any element matches with the searched element otherwise it will return 0.



C++ Structures

In the C/C++ programming language, the structure is user-defined data types that allow us to store the combination of different data types together. All the …
Read More

C++ Static Keyword

Static s a keyword in C++ that is when used with different types gives different meanings. static keyword can be used with variables in a …
Read More

C++ Templates

Templates in C++ are the powerful feature that allows us to write generic programs (generic classes and generic functions). A single class or function is …
Read More

C++ Friend Function

There are private and protected members in a class that is inaccessible from outside of the class, constituting one of the concepts of object-oriented programming …
Read More

this Pointer in C++

In C++, this is a keyword that refers to the current instance of a class and this pointer holds the address or points to the …
Read More

Inheritance in C++

Inheritance is one of the most important concepts of object-oriented programming. In C++, inheritance is the process of deriving the properties and behaviors of one …
Read More