10 Mar 2013

Largest Element in 1-D Array

/*

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;


}

Categories: , , , ,

Related Posts:

  • Prime_Composite /* program to check entered number is prime or composite....   */ #include<iostream.h> #include<conio.h> void main() { int n,i=2,a=0; clrscr(); cout<<"Enter th number=… Read More
  • ugly_number /*program to generate nth ugly number Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... shows the first 11 ugly numbers. By convention, 1 is includ… Read More
  • pattern_rectangle /* program to print following pattern *********************** *                     * *                     * *&… Read More
  • Fibonacci series /*       program to generate Fibonacci series in C++.  */   #include<iostream.h>#include<conio.h>int main(){clrscr();unsigned long first,second,third,n;first=0; second=… Read More
  • pattern_nested loops /* program in c to print following pattern... &  &  &  &  &  &  &    &  &  &  &  &       … Read More

0 comments:

Post a Comment

Copyright © 2025 UPgradeCODING | Powered by Blogger