You are on page 1of 12

CSE 215L: Programming Language

II Lab
Faculty: Silvia Ahmed,
Sec – 9, 10
Lab 5 – Spring 2021
Task 01 & Task 02
• Read the array and use loop to print the result.
Task 03
• Read the array and when you read a number store the number
in a different array but before that check if the second array
already contains the same number or not.
• If not then store the new number in the second array.
• When the actual array is already visited once, print the second
array.
Task 04
• Declare an array of size 50.
• Start from 2 and increment the numbers by one in a loop and
divide the number by the numbers stored in the array if they
are greater than 0.
• If not divisible then store the number in the array index that is
still not occupied.
• Use a counter to count the prime numbers stored in the array.
Task 05
• Declare an array of size 10 for example int arr [10].
• Use loop 100 times and each time generate int num = (int)
(Math.random() * 10)and increment the index, arr[num]++.
Task 06, Task 07 & Task 08
• Follow the methods and instruction.
• Use formula for verification.
Task 09
• Take input for the array.
• In the main method, use a loop to invoke method with a
column index.
• Inside the loop use:
for(int row = 0; row < array.length; row++)
{
sum += array[row][columnIndex];}
Return the result to the main method.
• Print the result.
Task 10
• Major diagonal is the index where row == column.
• Inside the method,
for(int row = 0; row < array.length; row++)
{
for(int column= 0; column < array[row].length; column ++)
{if(row == column)
sum += array[row][column];}
}
Task 11
• Do the problem as task 09 for finding the sum of individual
columns and then to find the sum of individual rows.
• Then find the first largest sum for row and column
respectively.
Task 12
• Use a loop and compare the inputs while taking them from
user.
• Also take note the row and column index at the same time
inside that loop.
• Print the result.
Task 13
• Do the problem as task 09 for finding the sum of individual
columns.
• Check whether each of the sums is equal to 1 or not.
• If all the sums are 1 then print it is a MarkovMatrix else not.
Task 14
• Take inputs for the two arrays.
• Use loop:
• boolean eq = true.
for(in row = 0; row < array.length; row++)
{
for(in column= 0; column < array[row].length; column ++)
{if(m1[row][column] != m2[row][column] )
eq = false;}
}
If (eq) print strictly identical else print not strictly identical

You might also like