0% found this document useful (0 votes)
1 views

practiceLab3

The document outlines a practice lab with five programming tasks involving arrays and matrices. Tasks include storing unique numbers in an array, rotating an array, calculating diagonal sums of a square matrix, checking for matrix symmetry, and managing student scores with a passing criteria. Each task provides examples and expected outputs for clarity.

Uploaded by

Khadija R
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)
1 views

practiceLab3

The document outlines a practice lab with five programming tasks involving arrays and matrices. Tasks include storing unique numbers in an array, rotating an array, calculating diagonal sums of a square matrix, checking for matrix symmetry, and managing student scores with a passing criteria. Each task provides examples and expected outputs for clarity.

Uploaded by

Khadija R
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/ 2

PRACTICE LAB 3

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

Array: { 5, 2, 7, 8, 3, 1, 12, 4, 34, 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

Q3: Write user defined functions for square matrix to calculate

1. Left diagonal sum


2. Right diagonal sum

Example:
Matrix:

3 4 7 6

2 8 2 9

1 6 2 3

5 1 7 3

Left Diagonal Sum: 3+8+2+3=16

Right Diagonal Sum: 6+2+6+5=19

Q4: Write a program to check whether a matrix is symmetric or not.

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.

You might also like