Tuesday 31 December 2013

C++ program to finding the maximum element in an array

#include<conio.h>
#include<iostream.h>
#include<stdio.h>
void main()
{
      clrscr();

    int array[]={1,2,3,4,5};

  int var1=array[0];
  for(int i=1;i<=5;i++)
   {  if(var1<array[i])
       var1=array[i];
   }
  cout<<var1;
       getch();

}

No comments:

Post a Comment