You are on page 1of 1

Introduction To Computing

Lab Final Term Examination Fall 2022 (V2)

Total Marks: 30 Total Duration: 1 hour 30 minutes


Note:

 There are total of two questions.


 Attempt all the questions. Each question carries equal marks.
 Submit zip folder containing two .cpp files on portal.

Question 1: Marks:15
Write a C++ program that reads maximum of 20 characters long words in two different
character arrays named “a” and “b” of same sizes and create a bigger third array c made of
first char of array “a” and second character of array “b” and so on. Any left-over characters go
at the end of the array “c”. Also, if the character is a symbol or a digit then do not copy it in the
third array “c”.

Sample Run1: Sample Run2: Sample Run3:


Input word for array a: abc Input word for array a: Hi!! Input word for array a: x123x67
Input word for array b: xyz Input word for array b: There Input word for array b: ya$x
Values stored in array c: axbycz Values stored in array c: HTihere Values stored in array c: xyxax

Question 2: Marks :15


Write a C++ program that reads 5 positive numbers from user in an array, assigns each number
some weight based on the following conditions and calculates and displays the sum of weights
assigned:

 The program assigns weight of 5 if the number is a prime number.


 The program assigns weight of 4 if the number is multiple of 4 and divisible by 6.
 The program assigns weight of 0 if none of the above condition satisfied.

Sample Run:
Input 5 numbers in array: 2 5 28 24 8
weights assigned: 5 5 0 4 0
The sum of weights: 14

You might also like