/*
program to compute the largest element in 1-D array....
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void max(int [],int);
void main()
{
clrscr();
int a,b,len[100];
cout<<"Enter the range of array:";
cin>>a;
cout<<"Enter the elements of the array:";
for(b=0;b<a;b++)
{
cin>>len[b];
}
max(len,a);
getch();
}
void max (int n[],int size)
{
int lar,i;
lar=n[0];
for(i=0;i<size;i++)
{
if(n[i]>lar)
lar=n[i];
}
cout<<"The largest element is: "<<lar;
}
program to compute the largest element in 1-D array....
*/
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void max(int [],int);
void main()
{
clrscr();
int a,b,len[100];
cout<<"Enter the range of array:";
cin>>a;
cout<<"Enter the elements of the array:";
for(b=0;b<a;b++)
{
cin>>len[b];
}
max(len,a);
getch();
}
void max (int n[],int size)
{
int lar,i;
lar=n[0];
for(i=0;i<size;i++)
{
if(n[i]>lar)
lar=n[i];
}
cout<<"The largest element is: "<<lar;
}
0 comments:
Post a Comment