0% found this document useful (0 votes)
15 views2 pages

Arrays: Introduction To Computing Lab-XII

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 2

Introduction to Computing

Lab-XII
 Arrays
Task 01: Write a C++ program that declares an array of 10 indexes. The program asks the user to choose
one of the initialization methods given in the following

1. Initialize all array values to be zeroes {0, 0, 0, 0, …….}


2. {0, 1, 2, 3,4 ,5, … }
3. {1, 2, 3,4 ,5, … }
4. {2, 4, 6, 8, 10, … }
5. {10, 15, 20, 25, 30, 35, …….} Starting from 10 with 5 more than the previous value.
6. {T*0, T*1, T*2, T*3, ………..} where T is entered by the user
7. {T*1, T*2, T*3, T*4, ………..} where T is entered by the user
Task 02: Write a C++ program that is able to find the minimum value from an integer array of 10

Task 03: Write a C++ program that is able to find the maximum value from an integer array of 10

Task 04: Write a C++ program that creates an array of 6 indices. The program initializes the indices like
{100, 101, 102, 103, 104, 105}. The program than swaps the value at first index with the value at last
index, value at second index with the value at second last index, and the value at third index with the
value at third last index. For an example, see the following

Initial array

100 101 102 103 104 105

After swapping indices

105 104 103 102 101 100

Task 05: Create two array called Array1 and Array2. Initialize Array1 with some random numbers.
Array2 is blank and same as size of Array1. Write a program that takes Array1 and Array2 and store
Values of Array1 in Array2 but in reverse order

Array1[10]= {2,4,5,66,75,8,53,11,3,45}
Array2[10]= { , , , , , , , , , }

Output:
Array1= {2,4,5,66,75,8,53,11,3,45}
Array2={45,3,11,53,8,75,66,5,4,2}
Task 06: Create an integer array of Size 10 and initialize it with some random numbers. Take an input
from user and create a function called finds that finds entered number into array and return index. It
returns -1 if number does not found.

Sample 1
Array[10]= {2,4,5,66,75,8,53,11,3,45}
Output:
Enter a number: 66
Index of number is: 3

Sample 2
Array[10]= {2,4,5,66,75,8,53,11,3,45}
Output:
Enter a number: 100
Number is not present

You might also like