CPP Program find the largest number in the array

 In this program, you will learn about the find the largest number in the array in the cpp programming language.

If you have knowledge about the c++ array, the c++ loop help in understanding the program.


#include <iostream>

using namespace std;

int main()


    int i, n;

    float arr[10]={1,2,3,4,5,6,7,8,9,10};

    // Loop to store largest number to arr[0]

    for(i = 1;i < n; ++i)


       // Change < to > if you want to find the smallest element

       if(arr[0] < arr[i])

           arr[0] = arr[i];


    cout << "Largest element  = " << arr[0]<<endl;

    return 0;


Largest element  = 10


Hire a programmer

Popular posts from this blog

CSS selector

C program to convert decimal to binary number

C Program to convert binary to decimal number