0% found this document useful (0 votes)
18 views1 page

Test Array

The document describes a menu-driven program that allows a user to: 1) input an array size N and integer array, 2) find the largest even negative number in the array, 3) calculate the total of odd numbers in the array, 4) calculate the greatest common divisor of all array elements, 5) display all sorted array elements, and 6) exit the program.

Uploaded by

Lý Phúc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

Test Array

The document describes a menu-driven program that allows a user to: 1) input an array size N and integer array, 2) find the largest even negative number in the array, 3) calculate the total of odd numbers in the array, 4) calculate the greatest common divisor of all array elements, 5) display all sorted array elements, and 6) exit the program.

Uploaded by

Lý Phúc
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Note: The program must be divided into modules (functions) and not allow using global

variables.
Write a menu-based program with the following menu:
1. Input N and array of integer numbers
2. Find the largest even negative number
3. Calculate total of the ODD numbers
4. Calculate greatest common divisor of all array members
5. Display all elements
6. Exit

Q1. Input N and array of integer numbers


When user chooses 1 from main menu, do the followings:
- First, display “N = ” and accept positive integer N (N < 100)
- Then, accept N integers and store them into array

Q2. Find the largest even negative number


When user chooses 2 from main menu, find the largest even negative number in the array
(which accept in the first menu) and return this value to the main function for printing out. Note:
If the array has not even negative number , return 0.

Q3. Calculate total of the odd numbers


When user chooses 3 from main menu, calculates total of all the odd numbers in the array and
prints it out (Note: if the array has not odd number, return 0)

Q4. Calculate Greatest common divisor

When user chooses 4 from main menu, calculate greatest common divisor of all
array members and return this value to the main function for printing out.

Example1:
Arr[0]=4 Arr[1]=6 Arr[2]=16 Arr[3]=14 Arr[4]=12
greatest common divisor of all array is: 2
Example2:
Arr[0]=4 Arr[1]= -6 Arr[2]=16 Arr[3]= -14 Arr[4]=12
greatest common divisor of all array is: 2
Q5. When user chooses 5 from menu: Sorted all elements by ascending and then display them

Q6. Exit

When user chooses 6 from main menu, the program will be exit.

You might also like