Pseudo code 2.
1 Reverse a string
BEGIN
DISPLAY “----Reverse the string---”
DISPLAY “Enter the string to reverse it”
PROMPT USER FOR c1
READ c1
FOR (x=0 TO (c1[x] NOT EQUAL TO NULL) ) STEP x=x+1
ENDFOR
DISPLAY “Reverse of the string is”
FOR ((x=x-1 TO ( x>=0) STEP i=i+1
DISPLAY c1[x]
ENDFOR
END
2. concatenation of 2 string
BEGIN
DECLARE i=0;
DISPLAY “---concatenation of two string----”
DISPLAY “Enter your first string”
PROMPT USER FOR c1
READ c1
DISPLAY “Enter your second string”
PROMPT USER FOR c2
READ c2
FOR (x=0 TO (c1[x] NOT EQUAL TO NULL)) STEP x=x+1
INCREMENT i BY 1
END FOR
FOR (x=0 TO (c2[x] NOT EQUAL TO NULL)) STEP x=x+1
C1[i]=c2[x]
INCREMENT i BY 1
END FOR
C1[i]=NULL
DISPLAY “After concatenation, the string is”,c1
END
Pseudo code 2.3palindrome
BEGIN
DECLARE l=0
DISPLAY “---check if the given string is palindrome or not ----”
DISPLAY “Enter the sring”
PROMPT USER FOR c1
READ C1
FOR (i=0 TO (C1[i] NOT EQUAL TO NULL)) STEP i=i+1
ENDFOR
FOR ((k=(i-1) AND j=0) TO j<((i-1)/2) STEP (k=k-1 AND j=j+1)
IF (c1[j] IS NOT EQUALS TO C1[k])
l=1
END IF
ENDFOR
IF (l=0)
DISPLAY “This given string is palindrome”
ELSE
DISPLAY “This given string is not palindrome”
ENDIF
END
Pseudo code 2.4 length of string
BEGIN
DISPLAY “----Find lenght of the string ----”
DISPLAY “Enter the string to get its length”
PROMPT USER FOR c1
READ c1
FOR (i=0 TO (c1[i] NOT EQUAL TO NULL)) STEP i=i+1
ENDFOR
DISPLAY “The length of the string is”, i
END
Pseudo code 3.1 addition of matrix
BEGIN
DISPLAY "---Matrix addition---"
DISPLAY “Enter rows:-”
PROMPT USER FOR rows
READ rows
DISPLAY “Enter columns:-”
PROMPT USER FOR cols
READ cols
FOR(i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<col) STEP j=j+1
DISPLAY “----First matrix----”
DISPLAY “Enter the element of- Row:-:”, i, “COLUMN:”, j
PROMPT USER FOR a1[i][j]
READ a1[i][j]
ENDFOR
ENDFOR
FOR(i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<col) STEP j=j+1
DISPLAY “----Second matrix----”
DISPLAY “Enter the element of- Row:-:”, i, “COLUMN:”, j
PROMPT USER FOR a2[i][j]
READ a2[i][j]
ENDFOR
ENDFOR
DISPLAY “----First matrix----”
DISPLAY “FIRST MATRIX”
FOR (i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<col) STEP j=j+1
DISPLAY a1[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
DISPLAY “Second matrix”
FOR (i=0 TO i<rows) STEP i=i+1
FOR (j=0 TO j<cols) STEP j=j+1
DISPLAY a2[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
DISPLAY “----Sum of the matrices----”
FOR (i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<col) STEP j=j+1
a3[i][j]=a1[i][j]+a2[i][j]
DISPLAY a3[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
END
Pseudo code 3.2 subtraction of matrix
BEGIN
DISPLAY "----Matrix subtraction----"
DISPLAY “Enter rows:-”
PROMPT USER FOR rows
READ rows
DISPLAY “Enter columns:-”
PROMPT USER FOR cols
READ cols
FOR(i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<col) STEP j=j+1
DISPLAY “----First matrix----”
DISPLAY “Enter the element of- Row:-:”, i, “COLUMN:”, j
PROMPT USER FOR a1[i][j]
READ a1[i][j]
ENDFOR
ENDFOR
FOR(i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<col) STEP j=j+1
DISPLAY “----Second matrix----”
DISPLAY “Enter the element of- Row:-:”, i, “COLUMN:”, j
PROMPT USER FOR a2[i][j]
READ a2[i][j]
ENDFOR
ENDFOR
DISPLAY “----First matrix----”
DISPLAY “FIRST MATRIX”
FOR (i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<col) STEP j=j+1
DISPLAY a1[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
DISPLAY “Second matrix”
FOR (i=0 TO i<rows) STEP i=i+1
FOR (j=0 TO j<cols) STEP j=j+1
DISPLAY a2[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
DISPLAY “----Sum of the matrices----”
FOR (i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<col) STEP j=j+1
a3[i][j]=a1[i][j]-a2[i][j]
DISPLAY a3[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
END
Pseudo code 3.3 multiplication of matrix
BEGIN
DECLARE sum=0
DISPLAY “----Multiplication of two matrices----”
DISPLAY “First matrix”
DISPLAY “Enter the rows of first matrix:--
PROMPT USER FOR m
READ m
DISPLAY “Enter the columns of first matrix:--”
PROMPT USER FOR n
READ n
FOR (i=0 TO i<m) STEP i=i+1
FOR (j=0 TO j<n) STEP j=j+1
DISPLAY “Enter the element of- Row:-”, i, “Columns:-”, j
PROMPT USER FOR a1[i][j]
READ a1[i][j]
ENDFOR
ENDFOR
DISPLAY “SECOND MATRIX”
DISPLAY “Enter the rows of second matrix:--”
PROMPT USER FOR p
READ p
DISPLAY “Enter the columnss of second matrix:--”
PROMPT USER FOR q
READ q
IF (n IS NOT EQUAL TO p)
DISPLAY “Sorry, the entered orders of matrices can't be multiplied”
ELSE
FOR (i=0 TO i<p) STEP i=i+1
FOR (j=0 TO j<q) STEP j=j+1
DISPLAY “Enter the element of- Row:-”, i, “COLUMN:-”j
PROMPT USER FOR a2[i][j]
READ a2 [i][j]
ENDFOR
ENDFOR
FOR (i=0 TO i<row) STEP i=i+1
FOR (j=0 TO j<c) STEP j=j+1
FOR (k=0 TO k<col) STEP k=k+1
sum=sum+a1[i][k]*a2[k][j]
ENDFOR
a3[i][j]=sum
sum=0
ENDFOR
ENDFOR
DISPLAY “----First matrix----”
FOR (i=0 TO i<m) STEP i=i+1
FOR (j=0 TO j<n) STEP j=j+1
DISPLAY a1[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
DISPLAY “----Second matrix----”
FOR (i=0 TO i<p) STEP i=i+1
FOR (j=0 TO j<q) STEP j=j+1
DISPLAY a2[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
DISPLAY “----multiplication of both the matrices----”
FOR (i=0 TO i<m) STEP i=i+1
FOR (j=0 TO j<q) STEP j=j+1
DISPLAY a3[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
END
Pseudo code 3.4transpose of matrix
BEGIN
DISPLAY “----Transpose of matrix----”
DISPLAY “Enter rows:-”
PROMPT USER FOR rows
READ rows
DISPLAY “Enter columns:-”
PROMPT USER FOR cols
READ cols
FOR (i=0 TO i<rows) STEP i=i+1
FOR (j=0 TO j<cols) STEP j=j+1
DISPLAY “----Matrix----”
DISPLAY “Enter the element of- Row:-”, i, “Column:-”, j
PROMPT USER FOR a1[i][j]
READ a1[i][j]
ENDFOR
ENDFOR
DISPLAY “----Original matrix----”
FOR (i=0 TO i<rows) STEP i=i+1
FOR(j=0 TO j<cols) STEP j=j+1
DISPLAY a1[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
DISPLAY “----After transposing matrix----”
FOR (i=0 TO i<rows) STEP i=i+1
FOR (j=0 TO j<cols) STEP j=j+1
a2[i][j] = a1[j][i]
DISPLAY a2[i][j]
ENDFOR
DISPLAY NEWLINE
ENDFOR
END