#include<iostream.h>

#include<conio.h>

void main()

{

clrscr(); //to clear the screen

int i,n,x,large=0;

cout<<“How many numbers?”;

cin>>n;

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

{

cout<<“nEnter number “<<i+1<<“:”;

cin>>x;

if(x>large)

large=x;

}

cout<<“nnThe largest number is “<<large;

getch();

}

SajidUnfortunately I don't get the logic behind these statements. Can you please help me out with this code?

"if(x>large)

large=x;"

Neeraj MishraInitially 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.

annuI didnot get the logic behind cout<<"enter number"<<i+1<<":"; ???? What is the importance of <<i+1<<":" ????

S!r DoshHammerSee 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) .

Muhammad Abdullahit means when x is larger then large then save the value of x in large variable

vishnugood program works perfectly thank you

NandikaWhat will be it’s flowchart or algorithm?

Tarun Binwalthanks

Siddhantwhat if all the numbers are in negative?

AJu saved my skin. love u man

Kanchan AgrawalThank you. Will you please write a program using pointer which will take 5 no. and will display the greatest number.

DivyaHow to write largest of 4 no in given no