#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();

}

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

"if(x>large)

large=x;"

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) .

good program works perfectly thank you

What will be it’s flowchart or algorithm?

thanks