Monday, 7 April 2014

C++ : A Program For Finding The Largest Number in an Array

#include <iostream.h>
#include <conio.h>
void main()
{
cout<<"Enter ten numbers\n";
int a[10];
int i,large;
for (i=0;i<10;i++)   //for input values 
cin>>a[i];
large=a[0];
for(i=0;i<10;i++)    //to find the largest number 
{
if(a[i]>large)
large=a[i];
}
cout<<"largest number="<<large;
getch();
}

No comments:

Post a Comment