How to find largest number of a list of numbers entered through keyboard in C++ program

CWC
0 Min Read

C++ program to find largest number of a list of numbers entered through keyboard

#include 
#include 
using namespace std; 
int main() 
{ 
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<<"\n\nThe largest number is "<<large; 
return 0; 
}
Share This Article
Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

English
Exit mobile version