You are on page 1of 3

Faculty of Sciences Lab 9 CSC 210L

I. Guidelines:
o You should be working individually.
o Samples of input/output cases for some problems are provided.
o Make sure to submit your files to Google Classroom before the deadline. Otherwise your
work won’t be considered for grading.
o You should submit one folder that contains only your .cpp files. The folder should be named
as “Full name – Lab 8”.

II. Lab Description:


You are asked to solve the following problems using Visual C++. In the same solution, make sure to
create a separate project for each problem. This lab consists of six problems. Four graded problems
and two bonus problems

A. Graded Problems:

1. Consider Write a program that does the following:

o Declares an array arr of size 10.


o Calculates and prints the length of the array using the function sizeof
o Asks the user to enter the array values.
o Print the elements of the array.
o Increment all elements with even indices by 10 i.e. arr [0], arr[2], arr[4], etc. and print
the new values.
o Puts the new values into a new array arr2.
o Displays the values of array arr2 in reversed order.

Sample I/O:

CSC 210L – Lab 9


Faculty of Sciences Lab 9 CSC 210L

2. Write a program that declares an array of length 10, fill it by numbers from the user and
determine the number of occurrences of a number read from a user in the array.

Sample I/O:

3. Write a program that declares an array of length 10 and fill it by numbers from the user. The
program should then print the following:
o The maximum number in the array
o The minimum number in the array
o The sum of the odd numbers in the array
o The average of even numbers in the array.

Sample I/O:

CSC 210L – Lab 9


Faculty of Sciences Lab 9 CSC 210L

4. Write a program that prints the memory address of an array’s elements

Sample I/O:

B. Bonus Problems:

5. Write a program that declares an array of length 10, fill it by numbers from the user and then sort
the array in increasing order. The program then should print the array after sorting.

6. Write a program that declares an array of length 10, fill it by numbers from the user and then sort
the array in decreasing order. The program then should print the array after sorting.

CSC 210L – Lab 9

You might also like