0% found this document useful (0 votes)
30 views3 pages

Lab 01

The document outlines 5 tasks for a C++ programming lab. The tasks include comparing two integer arrays, finding the intersection of two arrays, printing a pattern using loops, deleting a number from an array, and searching an array for a number.

Uploaded by

Hafiz Hammad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

Lab 01

The document outlines 5 tasks for a C++ programming lab. The tasks include comparing two integer arrays, finding the intersection of two arrays, printing a pattern using loops, deleting a number from an array, and searching an array for a number.

Uploaded by

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

Lab 01

Task 1:
Write a C++ program in which, read two integer array from user. Compare both array and display
either both arrays are same or not.
Example 1:
Input:
Array 1: 1 2 3 4 5
Array 2: 1 2 3 4 5
Output:
Arrays are same.

Example 2:
Input:
Array 1: 1 2 3 5 4
Array 2: 1 2 3 4 5
Output:
Arrays are not same.

Task 2:
Write a C++ program in which, read two integer array from user. Take intersection of both array
and display the resultant array.
Example:
Input:
Array 1: 1 2 3 4 5
Array 2: 6 7 3 4 10
Output:
Array: 3 4

Task 3:
Write a C++ program in which, given pattern should be printed. You can only use loop
variables.
Code Loop Variable

int number=2; Here number is the loop variable


while (number <= 10) {
cout<<number;
number=number+2;
}

for (int i=0; i<5; i++) { Here i is the loop variable.


cout<<i;
}

Output:
5 9 13 17 21
8 14 20 26 32
11 19 27 35 43
14 24 34 44 54
17 29 41 53 65

Task 4:
Write a C++ program in which, read one integer array from user and an integer number. Your
task is to delete the number from array if it exists.
Example 1:
Input:
Array: 1 2 3 4 5
Number: 3
Output:
Array: 1 2 4 5

Example 2:
Input:
Array: 1 2 3 4 5
Number: 6
Output:
The number does not exist

Task 5:
Write a C++ program in which, read two integer array from user and an integer number. Your
task is to search the number from array if it exists.
Example 1:
Input:
Array: 1 2 3 4 5
Number: 3
Output:
The number 3 exist at Index 2.

You might also like