C++ program to find largest of three number and more

Function in C++ is very important in making large program Because function breaks large programs into smaller codes which is combined in main function. Here in this program we will find the maximum number from the numbers entered by user, Suppose user enters 5 number "3,4,5,6,9" then this program will display 9 as the largest number. See the output below and explanation after the code.

Function in C++ is very important in making large program Because function breaks large programs into smaller codes which is combined in main function. Here in this program we will find the maximum number from the numbers entered by user, Suppose user enters 5 number "3,4,5,6,9"  then this program will display 9 as the largest number. See the output below and explanation after the code.
 C++ max number output

```//coding by Himanshu singh
#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;

int max_num(int a[],int n)  //function max
{
int i,m=0;
for(i=0;i<n;i++)
{
if(a[i]>m)
m=a[i];
}
return m;
}

int main() //now Main starts
{
int max,i,n;
int a[50];
cout<<"How many number you want to insert: ";
cin>>n;
cout<<"Enter the numbers by pressing enter: n";
for(i=0;i<n;i++)
cin>>a[i];
max=max_num(a,n);
cout<<"The largest number is "<<max;
}```
(Note : I am using Dev C++ to implement this logic I also recommend you the same for you this is the best software for C++.)

Logic behind maximum no. code-:
The logic is very simple, first we include header files iostream & stdio. Using namespace std is for standard use of standard input output stream like cout.
Now here we first make a function which return maximum of the given number we take an array 'a' to store the numbers. And we run a for loop to get the max number, this loop simply checks the number in array line wise like a[1] then a[2] and so on and checks its value with the previous number and return the max no. comparing both of them this loop works till the value of n number means how many number user has given.
In main function the max function is called in a for loop and the maximum number found is stored in max variable. That's all. Run the program in DEV C++ and see the result you can modify this program.
Note : In C++ there is the predefined function to find maximum of the number i.e. max( number 1, number 2)  this will give max number from the given numbers.
This is the simple logic for implementation of maximum of given number. Hope you like this tutorial. Please do like and share it if you find it useful. Any suggestions, questions and request can be dropped into comment box below.

Name

ltr
item
MindxMaster: C++ program to find largest of three number and more
C++ program to find largest of three number and more
Function in C++ is very important in making large program Because function breaks large programs into smaller codes which is combined in main function. Here in this program we will find the maximum number from the numbers entered by user, Suppose user enters 5 number "3,4,5,6,9" then this program will display 9 as the largest number. See the output below and explanation after the code.
https://2.bp.blogspot.com/-YO2c8abJOks/VYGfPk-h3HI/AAAAAAAAAPY/CVRZJBNqRio/s1600/max%2Bnumber.png
https://2.bp.blogspot.com/-YO2c8abJOks/VYGfPk-h3HI/AAAAAAAAAPY/CVRZJBNqRio/s72-c/max%2Bnumber.png
MindxMaster
http://www.mindxmaster.com/2015/06/finding-max-from-n-number-introduction.html
http://www.mindxmaster.com/
http://www.mindxmaster.com/
http://www.mindxmaster.com/2015/06/finding-max-from-n-number-introduction.html
true
5332415103371288268
UTF-8