Tuesday, February 19, 2013

OOCP (CPP) : Example # 05 : Find out the maximum value from array using c++

OOCP (CPP)  :  Example # 05 : Find out the maximum value from array using c++

* Lets start learning CPP (C++) Using Example.

* Find out the maximum value from array using C++.

//Written by Latest Technology Guide    
//Title : OOCP (CPP)  :  Example # 
05 : Find out the maximum value from array using c++

#include <iostream.h>
#include <iomanip.h>
#include <conio.h>

class sort
{
private :
int value[100];
public :
void getvalue(int);
int maxvalue(int);
};
void sort :: getvalue(int n)
{
for(int i=0;i<n;i++)
{
cout << "Enter Value [" << i<< "] : ";
cin >> value[i];
}
}
int sort :: maxvalue(int n)
{
int max=value[0];

for(int i=1;i<n;i++)
{
if(max<value[i])
max = value[i];
}
return(max);
}

void main()
{
clrscr();
int n;
sort obj;

cout << "Enter the number of terms : " ;
cin >> n;

obj.getvalue(n);
cout << "Maximum value is : " << obj.maxvalue(n);

getch();
}


Output:
* you will find output as : Maximu value is : ??

--------------------------------------------------------------------------------
OOCP (CPP)  :  Example # 05 : Find out the maximum value from array using c++

* Example demonstrate how to find maximum value from array.


Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements. 

No comments:

Post a Comment