You are on page 1of 3

Name : Galib,Shaikh Allahma

ID : 20-42325-1

Section: E Course: Data Structure Lab

Submit to: Nazmus Sakib Shan

Problem1:
import java.util.Scanner;
public class pppp
{
public static void main(String args[])
{
int m, n, c, d;

Scanner in = new Scanner(System.in);


System.out.println("Enter the number of rows and columns of matrix");
m = in.nextInt();
n = in.nextInt();

int matrix[][] = new int[m][n];

System.out.println("Enter elements of the matrix");

for (c = 0; c < m; c++)


for (d = 0; d < n; d++)
matrix[c][d] = in.nextInt();
int transpose[][] = new int[n][m];

for (c = 0; c < m; c++)


for (d = 0; d < n; d++)
transpose[d][c] = matrix[c][d];

System.out.println("Transpose of the matrix:");

for (c = 0; c < n; c++)


{
for (d = 0; d < m; d++)
System.out.print(transpose[c][d]+"\t");

System.out.print("\n");
}
}
}

Problem 2:
public class pppp
{
public static void main(String args[])
{
String s="I am a student";
System.out.println("Sample String (s) : "+s);
char c=s.charAt(0);
char[] ch=s.toCharArray();
int len=ch.length;
int j=2;
System.out.println("Sample integer (j): "+j);
System.out.print("Converted string : ");
for ( int i=2; i<len; i+=3)
{
ch[i] = (char) (ch[i]+j);

}
String str =new String(ch);
System.out.print(str);
}
}

You might also like