C++ Program to Find Smallest Element in Array


Prev Tutorial Next Tutorial

Find Smallest Element in Array Program in C++

To write this code we receive input from user and store in array variable after that sort array elements and find smalles element.In this Code, we will find the smallest element of array by using linear search. Given an array of N elements, we have to find the Smallest Element of Array.

Examples To C++ Program Find Smallest Element from Array


Array : [9, 32, 11, -6, -4, 3, 0, -3]
Smallest Element : -6

To understand below example, you have must knowledge of following C++ programming topics; String in C++, for looping statements we need know For Loop in C++ and Array in C++.

Algorithm to Find Smallest Element of Array

  • First take input from user as a size of Array
  • Then ask user to enter elements in Array
  • Initialize one variables smallest with first element of inputArray.
  • Using Loop traverse array from 0 to N-1 and compare each element with smallest. If current element is less than smallest, then update smallest with current element.
  • After array traversal smallest will have the smallest element.

C++ Program to Find Smallest Elements from Array


void main(){
    int array[100], count, i, smallest;
    cout<<"Enter Number of Elements in Array\n";
    cout<<"Enter Any"<<count<<" Elemnts in Array \n";
    // Read array elements
    for(i = 0; i < count; i++){
    smallest = array[0];
    // search num in inputArray from index 0 to elementCount-1 
    for(i = 0; i < count; i++){
        if(array[i] < smallest){
            smallest = array[i];
    cout<<"Smallest Element is:\n"<<smallest;


Enter Number of Elements in Array: 5
Enter Any 5 Elements in Array
c++ program to find smallest elements form array
Prev Tutorial Next Tutorial


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements

Buy Websites 9999595223
wifi cctv camera

Wifi CCTV Camera RS:1200 to 2499. Contact no. 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs