C++ Find the Maximum & Minimum Element in an Integer Array

C++ Find the Maximum & Minimum Element in an Integer Array




 

#include<iostream.h>
void max_min()
{
int a[5];
cout<<”Enter 5 values:\n”;
for(int i=0;i<=4;i++)
{
cin>>a;
}
int *max,*min;
max=&a[0];
min=&a[0];
for(int j=0;j<5;j++)
{
if(a[j]<*min)
{
min=&a[j];
}
else if(a[j]>*max)
{
max=&a[j];
}}
cout<<”The Maximum Value =”<<*max;
cout<<”\n”;
cout<<”The Minimum Value=”<<*min;
}
void main()
{
max_min();
}

Click here for more C++ Programs

info@C++

C++ (pronounced “cee plus plus”).C++ is a general-purpose,powerful programming language.C++ is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. C++ was Developed by Bjarne Stroustrup starting in 1979.C++ adds OOPS-object oriented features such as classes, and other enhancements to the C programming language.


Rate this post




Further Reading:
http://en.wikipedia.org/wiki/Find
http://en.wikipedia.org/wiki/Maximum
http://en.wikipedia.org/wiki/Minimum
http://en.wikipedia.org/wiki/Element
http://en.wikipedia.org/wiki/Integer

You read About:C++ Find the Maximum & Minimum Element in an Integer Array

Posted by: Prateek on October 6, 2011


Previous Post: « Next Post: »

© 2017 Trendfy. All rights reserved
Blog Managed by Prateek Jaiswal