Uploaded by zoloman Khan

Assignment 05 (1)

advertisement
University of Central Punjab
Faculty of Information Technology
Assignment 05
Subject: SECP1013 ITCStudent Name:
Reg. No:
Date: 13/1/2020
Due Date: 17/01/2021
Total points: 40
Question 1:
Write C++ statements to do the following:
a. Declare an array alpha of 15 components of type int.
b. Output the value of the tenth component of the array alpha.
c. Set the value of the fifth component of the array alpha to 35.
d. Set the value of the ninth component of the array alpha to the sum of the sixth and thirteenth
components of the array alpha.
e. Set the value of the fourth component of the array alpha to three times the value of the eighth
component minus 57.
f. Output alpha so that five components per line are printed.
Question 2:
Write a C++ program that reads an integer number from the user as an input. It should then separate
the digits and stores each in an array. The user can enter up to 8 digits. The program prints a new
number on the screen using the following rule:
Numbers with odd count of digits is rotated about the middle number and if the count of digits is even
then it is rotated about the 2 middle digits. In order to understand this question, see the example
below.
The numbers having the same color are swapped to produce the rotated new number:
Question 3:
Write a C++ program that keeps on getting numbers from the user in an array. The maximum size of
the array is 100. The user keeps on entering the values till -99 is entered. The program then prints the
second minimum, second maximum, count of prime numbers, total count, sum and average of all the
entered numbers.
Example: If the user entered 6 12 9 234 623 -99 then the program should print
Second Min= 9, Second Max= 234, Prime Count= 0, Total Count = 5, Sum = 884 and Average =
176.8
Download