Code:
#include<iostream.h>
#include<conio.h>
int arraymax(int arr[],int size)
{
int max=0;
for(int i=0;i<size;i++)
{
if(arr[i]>max)
{
max=arr[i];
}
}
return max;
}
void main()
{
clrscr();
int i,n, A[100];
cout<<"Enter the number of elements needed in the array[less than 100]: ";
cin>>n;
cout<<"\nEnter the elements: ";
for(i=0;i<n;i++)
cin<<a[i];
cout<<"\nLargest element in the array is: "<<arraymax(A,n);
getch();
}
Output:
Enter the number of elements needed in the array[less than 100]: <number less than 1000>
Enter the elements: <number 1>
<number 2>
<number 3>
<.>
<.>
<number n>
Largest element in the array is: <largest of those^ numbers>