SlideShare a Scribd company logo
1 of 15
Programming
Sample Input: Sample Output:
3 8
8 11
Question 1
Write a Java code to add the given two matrices.
row = 2
column = 2
m1[][]
1 3
7 8
m2[][]
2 5
1 3
import java.util.Scanner;
public class Main{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int row = sc.nextInt();
int column = sc.nextInt();
int m1[][] = new int[row][column];
for(int i = 0; i < row; i++){
for(int j = 0; j < column; j++){
m1[i][j] = sc.nextInt();
}
}
int m2[][] = new int[row][column];
for(int i = 0; i < row; i++){
for(int j = 0; j < column; j++){
m2[i][j] = sc.nextInt();
}
}
int sum[][] = new int[row][column];
addition(m1, m2, sum);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public static void addition(int m1[][], int m2[][], int sum[][])
{
for(int i = 0; i <= sum.length - 1; i++)
{
for(int j = 0; j <= sum[i].length - 1; j++)
{
sum[i][j] = m1[i][j] + m2[i][j];
}
}
for(int i = 0; i <= sum.length - 1; i++)
{
for(int j = 0; j <= sum[i].length - 1; j++)
{
System.out.print(sum[i][j] + " ");
}
System.out.println();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Question 2
Write a Java code to find the transpose of a given matrix.
Sample Input:
r = 2
c = 3
matrix[][]
1 3 7
5 4 9
Sample Output:
1 5
3 4
7 9
import java.util.Scanner;
class Main{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int r = in.nextInt();
int c = in.nextInt();
int matrix[][] = new int[r][c];
for(int i = 0; i < r; i++)
{
for(int j = 0; j < c; j++)
{
matrix[i][j] = in.nextInt();
}
}
int transpose[][] = new int[c][r];
for(int i = 0; i <= r-1; i++)
{
for(int j = 0; j <= c-1; j++)
{
transpose[j][i] = matrix[i][j];
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
for(int i = 0; i <= c-1; i++)
{
for(int j = 0; j <= r-1; j++)
{
System.out.print(transpose[i][j] + " ");
}
System.out.println();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Sample Input: Sample Output:
5 14
22 59
Question 3
r1 = 2, c1 = 2
a[][]
1 3
7 8
r2 = 2, c2 = 2
b[][]
2 5
1 3
Write a Java code to multiply two matrices.
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner in = new Scanner(System.in);
int r1 = in.nextInt();
int c1 = in.nextInt();
int a[][] = new int[r1][c1];
for(int i = 0; i < r1; i++){
for(int j = 0; j < c1; j++){
a[i][j] = in.nextInt();
}
}
int r2 = in.nextInt();
int c2 = in.nextInt();
int b[][] = new int[r2][c2];
for(int i = 0; i < r2; i++){
for(int j = 0; j < c2; j++){
b[i][j] = in.nextInt();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
if(c1 != r2){
System.out.print("Invalid Input");
return;
}
int result[][] = new int[r1][c2];
multiplication(a, b, result);
for(int i = 0; i < r1; i++){
for(int j = 0; j < c2; j++){
System.out.print(result[i][j] + " ");
}
System.out.println();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public static void multiplication(int a[][], int b[][], int result[][])
{
for(int i = 0; i < a.length; i++)
{
for(int j = 0; j < b[i].length; j++)
{
for(int k = 0; k < a[i].length; k++)
{
result[i][j] = result[i][j] + a[i][k] * b[k][j];
}
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Sample Input: Sample Output:
Question 4
3
America
Java
Alpha
Write a Java code to print the words which starts with a vowel.
America
Alpha
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int col_size = sc.nextInt();
String[][] str = new String[1][col_size];
for(int col_idx = 0; col_idx < col_size; col_idx++)
{
str[0][col_idx] = sc.next();
}
for(int col_idx = 0; col_idx < col_size; col_idx++)
{
char c = str[0][col_idx].charAt(0);
if(c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o'
|| c=='O' || c=='u' || c=='U')
System.out.println(str[0][col_idx]);
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
THANK YOU

More Related Content

Similar to WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-2D_Program_1.1.pptx

Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaanwalia Shaan
 
Demonstrating bully algorithm in java
Demonstrating bully algorithm in javaDemonstrating bully algorithm in java
Demonstrating bully algorithm in javaNagireddy Dwarampudi
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptxKimVeeL
 
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdfSolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdfannaimobiles
 
Computer java programs
Computer java programsComputer java programs
Computer java programsADITYA BHARTI
 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docxdavinci54
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfanjanacottonmills
 
import java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfimport java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfanithareadymade
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...MaruMengesha
 
Java 스터디 강의자료 - 1차시
Java 스터디 강의자료 - 1차시Java 스터디 강의자료 - 1차시
Java 스터디 강의자료 - 1차시Junha Jang
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfeyewatchsystems
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 

Similar to WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-2D_Program_1.1.pptx (17)

Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaan
 
Programs of java
Programs of javaPrograms of java
Programs of java
 
Demonstrating bully algorithm in java
Demonstrating bully algorithm in javaDemonstrating bully algorithm in java
Demonstrating bully algorithm in java
 
Lab01.pptx
Lab01.pptxLab01.pptx
Lab01.pptx
 
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdfSolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
SolutionSelection Sort after two iterations1 14 8 9 5 16 2 1.pdf
 
Computer java programs
Computer java programsComputer java programs
Computer java programs
 
LAB1.docx
LAB1.docxLAB1.docx
LAB1.docx
 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docx
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
 
import java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdfimport java.util.; public class DecimalToBinary { public stat.pdf
import java.util.; public class DecimalToBinary { public stat.pdf
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
 
WAP to add two given matrices in Java
WAP to add two given matrices in JavaWAP to add two given matrices in Java
WAP to add two given matrices in Java
 
JAVA.pdf
JAVA.pdfJAVA.pdf
JAVA.pdf
 
Java practical
Java practicalJava practical
Java practical
 
Java 스터디 강의자료 - 1차시
Java 스터디 강의자료 - 1차시Java 스터디 강의자료 - 1차시
Java 스터디 강의자료 - 1차시
 
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdfJava AssignmentWrite a program using sortingsorting bubble,sele.pdf
Java AssignmentWrite a program using sortingsorting bubble,sele.pdf
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 

More from MaruMengesha

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...MaruMengesha
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...MaruMengesha
 
Chemistry Student G9.pdf chemistry text book
Chemistry Student G9.pdf chemistry text bookChemistry Student G9.pdf chemistry text book
Chemistry Student G9.pdf chemistry text bookMaruMengesha
 
eco ppt.pptx Economics presentation Assignment
eco ppt.pptx Economics presentation Assignmenteco ppt.pptx Economics presentation Assignment
eco ppt.pptx Economics presentation AssignmentMaruMengesha
 
G12-Agriculture-STB-2023-web.pdf Agriculture text book
G12-Agriculture-STB-2023-web.pdf Agriculture text bookG12-Agriculture-STB-2023-web.pdf Agriculture text book
G12-Agriculture-STB-2023-web.pdf Agriculture text bookMaruMengesha
 

More from MaruMengesha (10)

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_15-Mar-2021_L15...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_11-Feb-2021_L5-...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_10-Feb-2021_L4_...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Mar-2021_L14...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_04-Feb-2021_L2_...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Mar-2021_L13...
 
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_03-Feb-2021_L1_...
 
Chemistry Student G9.pdf chemistry text book
Chemistry Student G9.pdf chemistry text bookChemistry Student G9.pdf chemistry text book
Chemistry Student G9.pdf chemistry text book
 
eco ppt.pptx Economics presentation Assignment
eco ppt.pptx Economics presentation Assignmenteco ppt.pptx Economics presentation Assignment
eco ppt.pptx Economics presentation Assignment
 
G12-Agriculture-STB-2023-web.pdf Agriculture text book
G12-Agriculture-STB-2023-web.pdf Agriculture text bookG12-Agriculture-STB-2023-web.pdf Agriculture text book
G12-Agriculture-STB-2023-web.pdf Agriculture text book
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 

WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-2D_Program_1.1.pptx

  • 1.
  • 3. Sample Input: Sample Output: 3 8 8 11 Question 1 Write a Java code to add the given two matrices. row = 2 column = 2 m1[][] 1 3 7 8 m2[][] 2 5 1 3
  • 4. import java.util.Scanner; public class Main{ public static void main(String args[]) { Scanner sc = new Scanner(System.in); int row = sc.nextInt(); int column = sc.nextInt(); int m1[][] = new int[row][column]; for(int i = 0; i < row; i++){ for(int j = 0; j < column; j++){ m1[i][j] = sc.nextInt(); } } int m2[][] = new int[row][column]; for(int i = 0; i < row; i++){ for(int j = 0; j < column; j++){ m2[i][j] = sc.nextInt(); } } int sum[][] = new int[row][column]; addition(m1, m2, sum); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 5. public static void addition(int m1[][], int m2[][], int sum[][]) { for(int i = 0; i <= sum.length - 1; i++) { for(int j = 0; j <= sum[i].length - 1; j++) { sum[i][j] = m1[i][j] + m2[i][j]; } } for(int i = 0; i <= sum.length - 1; i++) { for(int j = 0; j <= sum[i].length - 1; j++) { System.out.print(sum[i][j] + " "); } System.out.println(); } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 6. Question 2 Write a Java code to find the transpose of a given matrix. Sample Input: r = 2 c = 3 matrix[][] 1 3 7 5 4 9 Sample Output: 1 5 3 4 7 9
  • 7. import java.util.Scanner; class Main{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int r = in.nextInt(); int c = in.nextInt(); int matrix[][] = new int[r][c]; for(int i = 0; i < r; i++) { for(int j = 0; j < c; j++) { matrix[i][j] = in.nextInt(); } } int transpose[][] = new int[c][r]; for(int i = 0; i <= r-1; i++) { for(int j = 0; j <= c-1; j++) { transpose[j][i] = matrix[i][j]; } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 8. for(int i = 0; i <= c-1; i++) { for(int j = 0; j <= r-1; j++) { System.out.print(transpose[i][j] + " "); } System.out.println(); } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 9. Sample Input: Sample Output: 5 14 22 59 Question 3 r1 = 2, c1 = 2 a[][] 1 3 7 8 r2 = 2, c2 = 2 b[][] 2 5 1 3 Write a Java code to multiply two matrices.
  • 10. import java.util.Scanner; public class Main{ public static void main(String args[]){ Scanner in = new Scanner(System.in); int r1 = in.nextInt(); int c1 = in.nextInt(); int a[][] = new int[r1][c1]; for(int i = 0; i < r1; i++){ for(int j = 0; j < c1; j++){ a[i][j] = in.nextInt(); } } int r2 = in.nextInt(); int c2 = in.nextInt(); int b[][] = new int[r2][c2]; for(int i = 0; i < r2; i++){ for(int j = 0; j < c2; j++){ b[i][j] = in.nextInt(); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 11. if(c1 != r2){ System.out.print("Invalid Input"); return; } int result[][] = new int[r1][c2]; multiplication(a, b, result); for(int i = 0; i < r1; i++){ for(int j = 0; j < c2; j++){ System.out.print(result[i][j] + " "); } System.out.println(); } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 12. public static void multiplication(int a[][], int b[][], int result[][]) { for(int i = 0; i < a.length; i++) { for(int j = 0; j < b[i].length; j++) { for(int k = 0; k < a[i].length; k++) { result[i][j] = result[i][j] + a[i][k] * b[k][j]; } } } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
  • 13. Sample Input: Sample Output: Question 4 3 America Java Alpha Write a Java code to print the words which starts with a vowel. America Alpha
  • 14. import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int col_size = sc.nextInt(); String[][] str = new String[1][col_size]; for(int col_idx = 0; col_idx < col_size; col_idx++) { str[0][col_idx] = sc.next(); } for(int col_idx = 0; col_idx < col_size; col_idx++) { char c = str[0][col_idx].charAt(0); if(c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' || c=='u' || c=='U') System.out.println(str[0][col_idx]); } } } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22

Editor's Notes

  1. 1st slide (Mandatory)
  2. Input: r1 = 2, c1 = 2 a[][] 8 9 4 5 r2 =1, c2 =3 b[][] 1 2 3 Output: Invalid Input Description: As per matrix multiplication rule c1 should be equal to r2.
  3. Thank you slide