Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Write a program by declaring two functions maximum and minimum.

Initialize two-dimensional array of size 3*3 with integer numbers in


main function of the program. Pass array as parameter to function
maximum to find out maximum number and to function minimum to
find out minimum number. Display minimum and maximum numbers
from main function of the program.

 Firstly define a class Arraymaxmin.


 The class has a private member arr, which is a 3x3 integer array.
 The constructor Arraymaxmin initializes the array with the values passed to it.
 Then create a function maximum() which finds the maximum number.
 Now create a function minimum() which finds the minimum number.
 Then create main() function where we create an object of the Arraymaxmin class with
the array myArray.
 In this function we call the maximum() and minimum() functions to find the maximum
and minimum values respectively, and print them out.

The output of this program will be:

This output indicates that the maximum number in the array is 9 and the minimum number is 1.

You might also like