Algorithms Object Array
Algorithms Object Array
Program 1
Step 1: Start
Step 2: Declare an array arr of size 100, arr2 of size len, set J=0
Step 3: Read integers into array of len numbers
Step 4: run loop from I=0 to len
Step 5: compare the elements of two arrays at Ith position
Step 6: if they are equal, store the element in arr2[Jth] location
Step 7: increment I by 1
Step 8: end loop
Step 9: Print the array with common elements and loop
Step 10: Stop
Program 2
Program 3
Program 4
Start 1: Start
Step 2: Read hours and mins of Time1
Step 3: Read hours and mins of Time2
Step 4: Create a temporary object Time3
Step 5: Perform Time3->hours= Time1->hours+Time->hours
Step 6: Perform Time3->min= Time1>min+Time2>min
Step 7: If Time3.mins >=60 then
Step 8: Time3->hours+=Time3->min/60
Step 9: Time3->mins=Time3->min%60
Step 10: Display Time3
Step 11: Stop
Program 5
Step 1: Start
Step 2: Read the value of row and column and declare matrix A[r][c], B[r][c], C[r][c]
Step 3: Read the values in A[][] and B[][]
Step 4: Declare variable i=0, j=0
Step 5: Repeat until i < r
Step 6: Repeat until j < c
Step7: Perform C[i][j]=A[i][j] - B[i][j]
Step 8: Set j=j+1
Step 9: End inner loop
Step 10: Set i=i+1
Step 11: End outer loop
Step 12: display matrix C[][]
Step 13: Stop
Program 6
Step 1: Start
Step 2: Declare a matrix A[m][m]
Step 3: Read values in matrix A
Step 4: Run loop from I=0 to m
Step 5: Run loop from J=0 to m
Step 6: check if A[I][J] ≠ A[J][I] then
Step 7: Print array is not symmetric
Step 8: Terminate loop
Step 9: End loop
Step 10: End loop
Step 11: Print Array is symmetric
Step 12: Run loop from I=0 to m
Step 13: Set SUM1+= A[I][I]
Step 14: Set SUM2+=A[J][I]
Step 15: End loop
Step 16: Print SUM1 and SUM2
Step 17: Stop
Program 7
Step 1: Start
Step 2: Read rows and column in m and n
Step 3: Read values in array
Step 4: Run loop from I=0 to m
Step 5: Run loop from J=0 to m
Step 6: check if (I=0) or (I=(m-1)) or (J=0) or (J=(n-1))
Step 7: Print A[I][J]
Step 8: End loop
Step 9: End loop
Step 1: Start
Step 2: Read a matrix A[][] of mxm size
Step 3: Set RSUM=0, CSUM=0, D=0
Step 4: Run loop from I =0 to M
Step 5: D=D+A[I][I]
Step 6; End loop
Step 7: Run loop from I =0 to M
Step 8: Set RSUM=0, CSUM=0
Step 9: Run loop from J=0 to M
Step 10: RSUM=RSUM+A[I][J]
Step 11: CSUM=CSUM+A[J][I]
Step 12: end loop
Step 13: If CSUM ≠D or RSUM ≠ D then Set FLAG= FALSE
Step 14: Print Not Magic Square
Step 15: terminate loop
Step 16: End loop
Step 17: If FLAG=TRUE then
Step 18: Print Magic Square
Step 19: Stop
Step 1: Start
Step 2: Read elements in matrix MAT[][] of mxm size
Step 3: Run loop from I=0 to M
Step 4: Set MINROW=MAT[I][0] and COLIND = 0
Step 5: Run loop J=1 to M
Step 6: If MINROW> MAT[I][J] then
Step 7: MINROW=MAT[I][J] and COLIND=J
Step 8: End loop
Step 9: Run loop K=0 to M
Step 10: If MINROW< MAT[K][COLIND] then end loop
Step 11: If K=M then
Step 12: Print Saddle point is MINROW
Step 13: end loop
Step 13: Stop
STEP 1: START
STEP 6: if(rows!=cols)
then PRINT "Matrix should be a square matrix" else Go to step 7