SlideShare a Scribd company logo
www.eazynotes.com Radha Gupta, BCA 5th
Sem. [2008-11 Batch], PCTE Page No. 1
/**** Program to Add Two Matrices ****/
import java.lang.*;
import java.io.*;
class addmatrix
{
static void add()
{
int a[][], b[][], c[][];
a = new int[2][2];
b = new int[2][2];
c = new int[2][2];
DataInputStream dts=new DataInputStream(System.in);
try
{
System.out.println("enter first matrix
2*2 order :");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
a[i][j]=Integer.parseInt(dts.readLine());
}
}
System.out.println("enter second matrix
2*2 order :");
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
www.eazynotes.com Radha Gupta, BCA 5th
Sem. [2008-11 Batch], PCTE Page No. 2
{
b[i][j]=Integer.parseInt(dts.readLine());
}
}
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
}
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
System.out.print(c[i][j]+" ");
}
System.out.println("t");
}
}
catch(Exception x)
{
System.out.println("error");
}
}
public static void main(String arg[])
{
add();
}
}
www.eazynotes.com Radha Gupta, BCA 5th
Sem. [2008-11 Batch], PCTE Page No. 3
Output:

More Related Content

ODP
Pick up the low-hanging concurrency fruit
ZIP
とある断片の超動的言語
PDF
Gpars workshop
PDF
GPars howto - when to use which concurrency abstraction
TXT
PPT
Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...
ODP
Concurrency on the JVM
PPTX
Ac cuda c_5
Pick up the low-hanging concurrency fruit
とある断片の超動的言語
Gpars workshop
GPars howto - when to use which concurrency abstraction
Psycopg2 postgres python DDL Operaytions (select , Insert , update, create ta...
Concurrency on the JVM
Ac cuda c_5

What's hot (20)

PDF
20160616技術會議
PPTX
Java practice programs for beginners
PPTX
Ac cuda c_4
PDF
Reason and GraphQL
PPTX
Synapse india dotnet development overloading operater part 4
PDF
Clojure functions midje
PPTX
“Tasks” in NetLogo 5.0beta1
PDF
New features in 3.0
PPTX
Java Performance Tweaks
ODP
XML-RPC vs Psycopg2
PDF
Ganga: an interface to the LHC computing grid
PDF
MySQL User Conference 2009: Python and MySQL
PDF
オープンデータを使ったモバイルアプリ開発(応用編)
PDF
"Ускорение сборки большого проекта на Objective-C + Swift" Иван Бондарь (Avito)
DOCX
PDF
AJUG April 2011 Raw hadoop example
PDF
Functional Programming with Clojure
PDF
The Ring programming language version 1.5.4 book - Part 26 of 185
PDF
Test Driven Development iOS에 적용해보기
PDF
Google App Engine Developer - Day3
20160616技術會議
Java practice programs for beginners
Ac cuda c_4
Reason and GraphQL
Synapse india dotnet development overloading operater part 4
Clojure functions midje
“Tasks” in NetLogo 5.0beta1
New features in 3.0
Java Performance Tweaks
XML-RPC vs Psycopg2
Ganga: an interface to the LHC computing grid
MySQL User Conference 2009: Python and MySQL
オープンデータを使ったモバイルアプリ開発(応用編)
"Ускорение сборки большого проекта на Objective-C + Swift" Иван Бондарь (Avito)
AJUG April 2011 Raw hadoop example
Functional Programming with Clojure
The Ring programming language version 1.5.4 book - Part 26 of 185
Test Driven Development iOS에 적용해보기
Google App Engine Developer - Day3
Ad

Similar to Java program-to-add-two-matrices (20)

PPTX
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
PDF
Java Simple Programs
DOCX
java program assigment -2
PDF
JAVA.pdf
PPTX
rmrfnel;,;'sdc,hddguydgudfufdydydhfjguyju8y8
DOCX
Programs of java
PDF
Sam wd programs
PPTX
Java simple programs
PDF
&Y tgs P kii for
DOCX
.net progrmming part2
PPTX
Nested For Loops and Class Constants in Java
DOC
PDF
First come first serve scheduling algorithm (FCFS) is the process th.pdf
PDF
1.aimport java.util.Scanner;public class Diamond {   public st.pdf
PDF
DCN Practical
DOCX
Java file
DOCX
Java file
PDF
Java 8 lambda expressions
PPTX
Introduction to Git Source Control
DOCX
WAP to add two given matrices in Java
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_17-Feb-2021_L8-...
Java Simple Programs
java program assigment -2
JAVA.pdf
rmrfnel;,;'sdc,hddguydgudfufdydydhfjguyju8y8
Programs of java
Sam wd programs
Java simple programs
&Y tgs P kii for
.net progrmming part2
Nested For Loops and Class Constants in Java
First come first serve scheduling algorithm (FCFS) is the process th.pdf
1.aimport java.util.Scanner;public class Diamond {   public st.pdf
DCN Practical
Java file
Java file
Java 8 lambda expressions
Introduction to Git Source Control
WAP to add two given matrices in Java
Ad

More from University of Essex (8)

PDF
Anatomy of a breach - an e-book by Microsoft in collaboration with the EU
DOC
Semiconductor diodes
DOC
Diodes and semiconductors - an introduction
DOC
Voltage regulation in electronics
PDF
Zener diode and its applications in electronics
PDF
Java program-to-calculate-area-and-circumference-of-circle
PPTX
Self - healing materials
PPTX
Quotes of the day
Anatomy of a breach - an e-book by Microsoft in collaboration with the EU
Semiconductor diodes
Diodes and semiconductors - an introduction
Voltage regulation in electronics
Zener diode and its applications in electronics
Java program-to-calculate-area-and-circumference-of-circle
Self - healing materials
Quotes of the day

Recently uploaded (20)

PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Nekopoi APK 2025 free lastest update
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
top salesforce developer skills in 2025.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
ai tools demonstartion for schools and inter college
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Introduction to Artificial Intelligence
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Odoo Companies in India – Driving Business Transformation.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle
Nekopoi APK 2025 free lastest update
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
wealthsignaloriginal-com-DS-text-... (1).pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Operating system designcfffgfgggggggvggggggggg
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
top salesforce developer skills in 2025.pdf
Reimagine Home Health with the Power of Agentic AI​
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
ai tools demonstartion for schools and inter college
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Essential Infomation Tech presentation.pptx
Introduction to Artificial Intelligence
How to Migrate SBCGlobal Email to Yahoo Easily
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Odoo Companies in India – Driving Business Transformation.pdf

Java program-to-add-two-matrices

  • 1. www.eazynotes.com Radha Gupta, BCA 5th Sem. [2008-11 Batch], PCTE Page No. 1 /**** Program to Add Two Matrices ****/ import java.lang.*; import java.io.*; class addmatrix { static void add() { int a[][], b[][], c[][]; a = new int[2][2]; b = new int[2][2]; c = new int[2][2]; DataInputStream dts=new DataInputStream(System.in); try { System.out.println("enter first matrix 2*2 order :"); for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { a[i][j]=Integer.parseInt(dts.readLine()); } } System.out.println("enter second matrix 2*2 order :"); for(int i=0;i<2;i++) { for(int j=0;j<2;j++)
  • 2. www.eazynotes.com Radha Gupta, BCA 5th Sem. [2008-11 Batch], PCTE Page No. 2 { b[i][j]=Integer.parseInt(dts.readLine()); } } for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { c[i][j]=a[i][j]+b[i][j]; } } for(int i=0;i<2;i++) { for(int j=0;j<2;j++) { System.out.print(c[i][j]+" "); } System.out.println("t"); } } catch(Exception x) { System.out.println("error"); } } public static void main(String arg[]) { add(); } }
  • 3. www.eazynotes.com Radha Gupta, BCA 5th Sem. [2008-11 Batch], PCTE Page No. 3 Output: