Data Strcuture Lab - 01 AIUB
Data Strcuture Lab - 01 AIUB
1. Write C++ code to solve all the problems starting from slide 7 to 11.
To know how to solve basic programming problems with Loops, Arrays, and
Functions.
1. Initialize an array of 10 elements and print the array elements both in normal and
reverse order.
For example,
Input: 12 32 43 1 54 53 15 64 3 13
Output: 13 3 64 15 53 54 1 43 32 12
Problem Descriptions
Problem 2
2. Initialize an integer array of 10 elements and print how many numbers are odd and
how many numbers are even.
For example,
Input: 12 32 43 1 54 53 15 64 3 13
Output:
6 odd numbers
4 even numbers
Problem Descriptions
Problem 3
3. Write a function that takes TWO parameters to print all the odd numbers between
a given range. Input the starting value of the range and ending value of the range.
Then, send them as the parameters to your function.
For example,
Output:
Starting value: 12
Ending value: 23
13 15 17 19 21 23
Problem Descriptions
Problem 4
For example,
Input:
12 13 14 1 2 3 101 104 107
15 16 17 4 5 6 102 105 108
18 19 20 7 8 9 103 106 109
Output:
114 119 124
121 126 131
128 133 138
Problem Descriptions
Problem 5
For example,
Scenario 1
Input: 5
Output: 120
Scenario 2
Input: 4
Output: Error! Not a prime number.
Books