
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
C++ Program to Find Minimum Element in an Array using Linear Search
This is a C++ Program to find the minimum element of an array using Linear Search approach. The time complexity of this program is O(n).
Algorithm
Begin Assign the data element to an array. Assign the value at ‘0’ index to minimum variable. Compare minimum with other data element sequentially. Swap values if minimum value is more then the value at that particular index of the array. print the minimum value. End
Example Code
#include<iostream> using namespace std; int main() { int n, i, minimum, a[10] = {1, 6, 7, 10, 12, 14, 12, 16, 20, 26}; char ch; minimum = a[0]; cout<<"\nThe data element of array:"; for(i = 0; i < 10; i++) { cout<<" "<<a[i]; if(minimum > a[i]) minimum= a[i]; } cout<<"\n\nMinimum of the data elements of array using linear search is: "<<minimum; return 0; }
Output
The data element of array: 1 6 7 10 12 14 12 16 20 26 Minimum of the data elements of array using linear search is: 1
- Related Articles
- How to find minimum element in an array using linear search in C language?
- C++ Program to Find the Minimum element of an Array using Binary Search approach
- How to find minimum element in an array using binary search in C language?
- C++ Program to Find Maximum Element in an Array using Binary Search
- C program to search an array element using Pointers.
- PHP program to find the minimum element in an array
- Swift Program to Search an Element in an Array
- C++ Program to Find the peak element of an array using Binary Search approach
- C# program to find maximum and minimum element in an array\n
- Write a Golang program to search an element in an array
- Java Program to Recursively Linearly Search an Element in an Array
- Program to find the minimum (or maximum) element of an array in C++
- C++ program to search an element in a sorted rotated array
- Write a Golang program to find the element with the minimum value in an array
- Write a Golang program to search an element in a sorted array

Advertisements