practiceLab3
practiceLab3
SEF21 (PF)
18-04-2022
Q1: Write a program that declares an array of size 10. Now ask user to enter positive numbers
and store only the unique numbers in the array. Stop taking input when the array fills. At the
end, display the array and also how many numbers are entered by user.
Example:
Enter number: 5
Enter number: 5
Enter number: 2
Enter number: 7
Enter number: 8
Enter number: 7
Enter number: 5
Enter number: 3
Enter number: 1
Enter number: 2
Enter number: 12
Enter number: 4
Enter number: 8
Enter number: 34
Enter number: 56
Number of entries: 15
Q2: Make an array of size 10. Input the number of times array is to be left rotated. Display the
original array and rotated array.
Example:
Original Array: 3 4 6 8 2 7
D=3:
Rotated array: 8 2 7 3 4 6
Example:
Matrix:
3 4 7 6
2 8 2 9
1 6 2 3
5 1 7 3
Q5: Take an array of 30 integers named Score and a second array named Passing. Assume
elements array Score contain scores for 30 students.
1. Write a code segment that initializes all students in Passing to false (zero).
2. Write a code segment that sets the students in Passing to true (one) wherever the
parallel value of Score is greater than 60.
3. Write a code segment that prints the index of the of items in Passing that are true (one).
4. Write a code segment that displays the count of the students who passed.