clrscr(); //to clear the screen
cout<<“How many numbers?”;
cout<<“nEnter number “<<i+1<<“:”;
cout<<“nnThe largest number is “<<large;
12 thoughts on “C++ program to find largest number of a list of numbers entered through keyboard”
Unfortunately I don't get the logic behind these statements. Can you please help me out with this code?
Initially large is 0, as a new number is entered i.e. x, is compared with large, if x is greater then large then large is update. After entering all numbers the final value of large is largest among all numbers.
I hope it will be clear now.
I didnot get the logic behind cout<<"enter number"<<i+1<<":"; ???? What is the importance of <<i+1<<":" ????
See there in the for loop the programmer used i<n that is it will run for n-1 (ex if n=3 then the loop will be for n=2) .
it means when x is larger then large then save the value of x in large variable
good program works perfectly thank you
What will be it’s flowchart or algorithm?
what if all the numbers are in negative?
u saved my skin. love u man
Thank you. Will you please write a program using pointer which will take 5 no. and will display the greatest number.
How to write largest of 4 no in given no