SlideShare a Scribd company logo
1 of 13
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Structured Programming Language
Arrays in C (1D & 2D)
Problem 1: Write a program that will take input two matrices and check their equality.
Input:
First line represents the no of rows and columns of the first matrix.
Then take input the elements of that matrix.
Next, you will take input the no of rows and columns of the second matrix.
Then take input the elements of that second matrix.
Output:
Yes (if both matrices are same)
No (otherwise)
Sample I/O:
input:
2 3
1 2 3
4 5 6
2 3
1 2 3
4 5 6
Output:
Yes
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 2: Write a program that will take input a matrix and show the transpose matrix in the output.
Note: The transpose of one matrix is another matrix that is obtained by using rows from the first matrix as
columns in the second matrix.
For example, it is easy to see that the transpose of matrix A is A'. Row 1 of matrix A becomes column 1 of A'; row
2 of A becomes column 2 of A' and row 3 of A becomes column 3 of A'.
A =
111 222
333 444
555 666
A' =
111 333 555
222 444 666
Note that the order of a matrix is reversed after it has been transposed. Matrix A is a 2 x 3 matrix, but matrix A' is
a 3 x 2 matrix.
Input:
First line represents the no of rows and columns of the first matrix.
Then take input the elements of that matrix.
Output:
The transpose matrix.
Sample I/O:
input:
2 3
1 2 3
4 5 6
Output:
1 4
2 5
3 6
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 3: Write a program that will take input a matrix and check whether it is an Identity matrix or not.
Note: The identity matrix is a square matrix which contains ones along the main diagonal (from the top left to the
bottom right), while all its other entries are zero. Such a matrix is of the form given below:
Input:
First line represents the no of rows and columns of the first matrix.
Then take input the elements of that matrix.
Output:
Yes (if identity)
No (otherwise)
Sample I/O:
input:
3 3
1 0 0
0 1 0
0 0 1
Output:
Yes
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 4: Write a program to find sum of elements of each column of a matrix.
Input:
First line represents the no of rows and columns of the first matrix.
Then take input the elements of that matrix.
Output:
a list representing the sum of elements of each column
Sample I/O:
input:
2 3
1 2 3
4 5 6
Output:
5 7 9
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 5: Write a program that will multiply two matrices and shows the final output matrix.
Input:
first line represents the rows and columns no of the first matrix.
Next take input the elements of the first matrix
Then, take input the rows and columns no of the second matrix.
Next take input the elements of the second matrix.
Output:
Invalid Dimension (if multiplication not possible due to invalid dimension)
or, show the product matrix.
Sample I/O:
input:
2 3
1 2 3
4 5 6
3 3
1 2 3
4 5 6
7 8 9
Output:
30 36 42
66 81 96
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 6: Write a C program to interchange the diagonals of a matrix.
Note:
Input:
first line represents the rows and columns no of the matrix. (row number = column number)
Next take input the elements of the matrix
Output:
diagonal interchanged matrix
Sample I/O:
input:
3 3
1 2 3
4 5 6
7 8 9
Output:
3 2 1
4 5 6
9 8 7
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 7: Write a C program that finds the sum of lower triangular matrix.
Note:
Input:
first line represents the rows and columns no of the matrix. (row number = column number)
Next take input the elements of the matrix.
Output:
an integer representing the sum of elements of lower triangular matrix.
Sample I/O:
input:
3 3
1 2 3
4 5 6
7 8 9
Output:
34
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 8: [Tic-Tac-Toe Win checker] Given a (3 X 3) matrix representing tic-tac-toe game board.
Note:
Input:
first line represents the rows and columns no of the matrix.
Next take input the elements (only ‘O’ or ‘X’ or ‘.(dot) ’) of the matrix.
Output:
Win O
or, Win X
or, Tie
Sample I/O:
input:
3 3
O O O
X O X
X . .
Output:
Win O
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 9: Write a C program that will take input a matrix as input and check whether it is symmetric or not.
Note:
Input:
first line represents the rows and columns no of the matrix. (row number = column number)
Next take input the elements of the matrix.
Output:
Yes (if symmetric)
No (otherwise)
Sample I/O:
input:
3 3
9 5 3
5 7 4
3 4 2
Output:
Yes
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 10: [Scarecrow Problem, 1D array] given an 1D array of the
following format, where F represents fields and S represents scarecrows.
F F F S F S F F F S
Input: take input an integer (n) representing the no of maximum fields a
scarecrow can guard.
Output: find out the array cells that the scarecrow can guard and replace the F to G.
The output array is shown below: for n=1
F F G S G S G F G S
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 11: Write a program that will take n integers into an array A and m positive integers into array B. Finally
find the intersection (set operation) of array A and B.
Input: first take input the size (n) of array A and then take input all the elements of A
Then take input the size of array B and then take input all the elements of B.
Output: an array holding the elements after intersection of array A and B.
Sample input Sample output
8
7 8 1 5 2 6 4 3
6
1 3 6 0 9 2
1 2 6 3
3
1 2 3
2
4 5
Empty set
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 12: Write a program that will take n integers into an array A and m positive integers into array B. Finally
find the union (set operation) of array A and B.
Input: first take input the size (n) of array A and then take input all the elements of A
Then take input the size of array B and then take input all the elements of B.
Output: an array holding the elements after union of array A and B.
Sample input Sample output
8
7 8 1 5 2 6 4 3
6
1 3 6 0 9 2
7 8 1 5 2 6 4 3 0 9
3
1 2 3
2
4 5
1 2 3 4 5
Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com
Problem 13: Write a program that will take n integers into an array and reverse all the integers within that array.
Finally print them all from 0 indexe to last valid index.
Input: first line of the input represents the size of array A then takes input all the elements of array A.
Sample input Sample output
5
1 2 3 4 5
5 4 3 2 1
6
2 8 3 9 0 1
1 0 9 3 8 2
Problem 14: Write a program that will take input n integers into an array A and then m integers into an array B.
Now swap all elements between array A and B. Finally show all elements of both array A and B.
Input: first line of the input represents the size of array A and then take input all the elements of array A
the next line represents the size of array B and then take input all the elements of array B.
Sample input Sample output
8
7 8 1 3 2 6 4 3
3
3 2 1
Array A : 3 2 1
Array B : 7 8 1 3 2 6 4 3

More Related Content

What's hot

vlsi training in chandigarh
vlsi training in chandigarhvlsi training in chandigarh
vlsi training in chandigarhmatrixphagwara
 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016Ankit Dubey
 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016Ankit Dubey
 
Taller número 1 de informática ll
Taller número 1 de informática llTaller número 1 de informática ll
Taller número 1 de informática llramivides
 
Epc assignment
Epc assignmentEpc assignment
Epc assignmentHồ Lợi
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17manjurkts
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressionsmaznabili
 
Chapter 3 branching v4
Chapter 3 branching v4Chapter 3 branching v4
Chapter 3 branching v4Sunarto Quek
 
Array & Exception Handling in C# (CSharp)
Array & Exception Handling in C# (CSharp)Array & Exception Handling in C# (CSharp)
Array & Exception Handling in C# (CSharp)Sohanur63
 
Basic Programming of c++
Basic Programming of c++Basic Programming of c++
Basic Programming of c++MMAbdullah17
 
Python - Control Structures
Python - Control StructuresPython - Control Structures
Python - Control StructuresLasithNiro
 
Ques c++ minhnd
Ques c++   minhndQues c++   minhnd
Ques c++ minhndCongdat Le
 

What's hot (17)

vlsi training in chandigarh
vlsi training in chandigarhvlsi training in chandigarh
vlsi training in chandigarh
 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016
 
Fy secondsemester2016
Fy secondsemester2016Fy secondsemester2016
Fy secondsemester2016
 
Taller número 1 de informática ll
Taller número 1 de informática llTaller número 1 de informática ll
Taller número 1 de informática ll
 
Epc assignment
Epc assignmentEpc assignment
Epc assignment
 
PS3
PS3PS3
PS3
 
C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17C Programming Lab manual 18CPL17
C Programming Lab manual 18CPL17
 
03 Operators and expressions
03 Operators and expressions03 Operators and expressions
03 Operators and expressions
 
Ch8 Arrays
Ch8 ArraysCh8 Arrays
Ch8 Arrays
 
Chapter 3 branching v4
Chapter 3 branching v4Chapter 3 branching v4
Chapter 3 branching v4
 
Array & Exception Handling in C# (CSharp)
Array & Exception Handling in C# (CSharp)Array & Exception Handling in C# (CSharp)
Array & Exception Handling in C# (CSharp)
 
Exercise2 java
Exercise2 javaExercise2 java
Exercise2 java
 
C quiz
C quizC quiz
C quiz
 
Introduction to computer_lec_04
Introduction to computer_lec_04Introduction to computer_lec_04
Introduction to computer_lec_04
 
Basic Programming of c++
Basic Programming of c++Basic Programming of c++
Basic Programming of c++
 
Python - Control Structures
Python - Control StructuresPython - Control Structures
Python - Control Structures
 
Ques c++ minhnd
Ques c++   minhndQues c++   minhnd
Ques c++ minhnd
 

Similar to SPL 12.1 | Multi Dimensional(Two) Array Practice Problems

Solving ONE’S interval linear assignment problem
Solving ONE’S interval linear assignment problemSolving ONE’S interval linear assignment problem
Solving ONE’S interval linear assignment problemIJERA Editor
 
C_Lab Manual_Part A.docx
C_Lab Manual_Part A.docxC_Lab Manual_Part A.docx
C_Lab Manual_Part A.docxPandiya Rajan
 
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21chinthala Vijaya Kumar
 
A study on solving Assignment Problem
A study on solving Assignment ProblemA study on solving Assignment Problem
A study on solving Assignment Problemvivatechijri
 
Data Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix MultiplicationData Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix Multiplicationbabuk110
 
Dti2143 dam31303 lab sheet 5
Dti2143 dam31303 lab sheet 5Dti2143 dam31303 lab sheet 5
Dti2143 dam31303 lab sheet 5alish sha
 
Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)IIUM
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 
Question đúng cnu
Question đúng cnuQuestion đúng cnu
Question đúng cnuPhamHoc
 
Practical java
Practical javaPractical java
Practical javanirmit
 
Assignment Poblems
Assignment Poblems Assignment Poblems
Assignment Poblems vkabre
 
Assignment problem
Assignment problemAssignment problem
Assignment problemAbu Bashar
 

Similar to SPL 12.1 | Multi Dimensional(Two) Array Practice Problems (20)

Mmt 001
Mmt 001Mmt 001
Mmt 001
 
Solving ONE’S interval linear assignment problem
Solving ONE’S interval linear assignment problemSolving ONE’S interval linear assignment problem
Solving ONE’S interval linear assignment problem
 
C_Lab Manual_Part A.docx
C_Lab Manual_Part A.docxC_Lab Manual_Part A.docx
C_Lab Manual_Part A.docx
 
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
CBSE Class 12 Computer Science(083) Sample Question Paper 2020-21
 
A study on solving Assignment Problem
A study on solving Assignment ProblemA study on solving Assignment Problem
A study on solving Assignment Problem
 
A01
A01A01
A01
 
A02
A02A02
A02
 
Data Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix MultiplicationData Structure & Algorithms - Matrix Multiplication
Data Structure & Algorithms - Matrix Multiplication
 
Dti2143 dam31303 lab sheet 5
Dti2143 dam31303 lab sheet 5Dti2143 dam31303 lab sheet 5
Dti2143 dam31303 lab sheet 5
 
Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)Tutorial 04 (revised) (1)
Tutorial 04 (revised) (1)
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Question đúng cnu
Question đúng cnuQuestion đúng cnu
Question đúng cnu
 
Practical java
Practical javaPractical java
Practical java
 
Assignment Poblems
Assignment Poblems Assignment Poblems
Assignment Poblems
 
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORYGE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
GE3171-PROBLEM SOLVING AND PYTHON PROGRAMMING LABORATORY
 
Assignment problem
Assignment problemAssignment problem
Assignment problem
 
OOP Assignment 03.pdf
OOP Assignment 03.pdfOOP Assignment 03.pdf
OOP Assignment 03.pdf
 
Programming Exam Help
 Programming Exam Help Programming Exam Help
Programming Exam Help
 
Pcd201516
Pcd201516Pcd201516
Pcd201516
 
Ansi c
Ansi cAnsi c
Ansi c
 

More from Mohammad Imam Hossain

DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchMohammad Imam Hossain
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionMohammad Imam Hossain
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaMohammad Imam Hossain
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaMohammad Imam Hossain
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckMohammad Imam Hossain
 

More from Mohammad Imam Hossain (20)

DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6DS & Algo 6 - Offline Assignment 6
DS & Algo 6 - Offline Assignment 6
 
DS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic ProgrammingDS & Algo 6 - Dynamic Programming
DS & Algo 6 - Dynamic Programming
 
DS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MSTDS & Algo 5 - Disjoint Set and MST
DS & Algo 5 - Disjoint Set and MST
 
DS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path SearchDS & Algo 4 - Graph and Shortest Path Search
DS & Algo 4 - Graph and Shortest Path Search
 
DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3DS & Algo 3 - Offline Assignment 3
DS & Algo 3 - Offline Assignment 3
 
DS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and ConquerDS & Algo 3 - Divide and Conquer
DS & Algo 3 - Divide and Conquer
 
DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2DS & Algo 2 - Offline Assignment 2
DS & Algo 2 - Offline Assignment 2
 
DS & Algo 2 - Recursion
DS & Algo 2 - RecursionDS & Algo 2 - Recursion
DS & Algo 2 - Recursion
 
DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1DS & Algo 1 - Offline Assignment 1
DS & Algo 1 - Offline Assignment 1
 
DS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL IntroductionDS & Algo 1 - C++ and STL Introduction
DS & Algo 1 - C++ and STL Introduction
 
DBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMSDBMS 1 | Introduction to DBMS
DBMS 1 | Introduction to DBMS
 
DBMS 10 | Database Transactions
DBMS 10 | Database TransactionsDBMS 10 | Database Transactions
DBMS 10 | Database Transactions
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
 
DBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship ModelDBMS 2 | Entity Relationship Model
DBMS 2 | Entity Relationship Model
 
DBMS 7 | Relational Query Language
DBMS 7 | Relational Query LanguageDBMS 7 | Relational Query Language
DBMS 7 | Relational Query Language
 
DBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML CommandsDBMS 4 | MySQL - DDL & DML Commands
DBMS 4 | MySQL - DDL & DML Commands
 
DBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR SchemaDBMS 5 | MySQL Practice List - HR Schema
DBMS 5 | MySQL Practice List - HR Schema
 
TOC 10 | Turing Machine
TOC 10 | Turing MachineTOC 10 | Turing Machine
TOC 10 | Turing Machine
 
TOC 9 | Pushdown Automata
TOC 9 | Pushdown AutomataTOC 9 | Pushdown Automata
TOC 9 | Pushdown Automata
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity CheckTOC 8 | Derivation, Parse Tree & Ambiguity Check
TOC 8 | Derivation, Parse Tree & Ambiguity Check
 

Recently uploaded

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 

Recently uploaded (20)

Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

SPL 12.1 | Multi Dimensional(Two) Array Practice Problems

  • 1. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Structured Programming Language Arrays in C (1D & 2D) Problem 1: Write a program that will take input two matrices and check their equality. Input: First line represents the no of rows and columns of the first matrix. Then take input the elements of that matrix. Next, you will take input the no of rows and columns of the second matrix. Then take input the elements of that second matrix. Output: Yes (if both matrices are same) No (otherwise) Sample I/O: input: 2 3 1 2 3 4 5 6 2 3 1 2 3 4 5 6 Output: Yes
  • 2. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 2: Write a program that will take input a matrix and show the transpose matrix in the output. Note: The transpose of one matrix is another matrix that is obtained by using rows from the first matrix as columns in the second matrix. For example, it is easy to see that the transpose of matrix A is A'. Row 1 of matrix A becomes column 1 of A'; row 2 of A becomes column 2 of A' and row 3 of A becomes column 3 of A'. A = 111 222 333 444 555 666 A' = 111 333 555 222 444 666 Note that the order of a matrix is reversed after it has been transposed. Matrix A is a 2 x 3 matrix, but matrix A' is a 3 x 2 matrix. Input: First line represents the no of rows and columns of the first matrix. Then take input the elements of that matrix. Output: The transpose matrix. Sample I/O: input: 2 3 1 2 3 4 5 6 Output: 1 4 2 5 3 6
  • 3. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 3: Write a program that will take input a matrix and check whether it is an Identity matrix or not. Note: The identity matrix is a square matrix which contains ones along the main diagonal (from the top left to the bottom right), while all its other entries are zero. Such a matrix is of the form given below: Input: First line represents the no of rows and columns of the first matrix. Then take input the elements of that matrix. Output: Yes (if identity) No (otherwise) Sample I/O: input: 3 3 1 0 0 0 1 0 0 0 1 Output: Yes
  • 4. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 4: Write a program to find sum of elements of each column of a matrix. Input: First line represents the no of rows and columns of the first matrix. Then take input the elements of that matrix. Output: a list representing the sum of elements of each column Sample I/O: input: 2 3 1 2 3 4 5 6 Output: 5 7 9
  • 5. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 5: Write a program that will multiply two matrices and shows the final output matrix. Input: first line represents the rows and columns no of the first matrix. Next take input the elements of the first matrix Then, take input the rows and columns no of the second matrix. Next take input the elements of the second matrix. Output: Invalid Dimension (if multiplication not possible due to invalid dimension) or, show the product matrix. Sample I/O: input: 2 3 1 2 3 4 5 6 3 3 1 2 3 4 5 6 7 8 9 Output: 30 36 42 66 81 96
  • 6. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 6: Write a C program to interchange the diagonals of a matrix. Note: Input: first line represents the rows and columns no of the matrix. (row number = column number) Next take input the elements of the matrix Output: diagonal interchanged matrix Sample I/O: input: 3 3 1 2 3 4 5 6 7 8 9 Output: 3 2 1 4 5 6 9 8 7
  • 7. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 7: Write a C program that finds the sum of lower triangular matrix. Note: Input: first line represents the rows and columns no of the matrix. (row number = column number) Next take input the elements of the matrix. Output: an integer representing the sum of elements of lower triangular matrix. Sample I/O: input: 3 3 1 2 3 4 5 6 7 8 9 Output: 34
  • 8. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 8: [Tic-Tac-Toe Win checker] Given a (3 X 3) matrix representing tic-tac-toe game board. Note: Input: first line represents the rows and columns no of the matrix. Next take input the elements (only ‘O’ or ‘X’ or ‘.(dot) ’) of the matrix. Output: Win O or, Win X or, Tie Sample I/O: input: 3 3 O O O X O X X . . Output: Win O
  • 9. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 9: Write a C program that will take input a matrix as input and check whether it is symmetric or not. Note: Input: first line represents the rows and columns no of the matrix. (row number = column number) Next take input the elements of the matrix. Output: Yes (if symmetric) No (otherwise) Sample I/O: input: 3 3 9 5 3 5 7 4 3 4 2 Output: Yes
  • 10. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 10: [Scarecrow Problem, 1D array] given an 1D array of the following format, where F represents fields and S represents scarecrows. F F F S F S F F F S Input: take input an integer (n) representing the no of maximum fields a scarecrow can guard. Output: find out the array cells that the scarecrow can guard and replace the F to G. The output array is shown below: for n=1 F F G S G S G F G S
  • 11. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 11: Write a program that will take n integers into an array A and m positive integers into array B. Finally find the intersection (set operation) of array A and B. Input: first take input the size (n) of array A and then take input all the elements of A Then take input the size of array B and then take input all the elements of B. Output: an array holding the elements after intersection of array A and B. Sample input Sample output 8 7 8 1 5 2 6 4 3 6 1 3 6 0 9 2 1 2 6 3 3 1 2 3 2 4 5 Empty set
  • 12. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 12: Write a program that will take n integers into an array A and m positive integers into array B. Finally find the union (set operation) of array A and B. Input: first take input the size (n) of array A and then take input all the elements of A Then take input the size of array B and then take input all the elements of B. Output: an array holding the elements after union of array A and B. Sample input Sample output 8 7 8 1 5 2 6 4 3 6 1 3 6 0 9 2 7 8 1 5 2 6 4 3 0 9 3 1 2 3 2 4 5 1 2 3 4 5
  • 13. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: imambuet11@gmail.com Problem 13: Write a program that will take n integers into an array and reverse all the integers within that array. Finally print them all from 0 indexe to last valid index. Input: first line of the input represents the size of array A then takes input all the elements of array A. Sample input Sample output 5 1 2 3 4 5 5 4 3 2 1 6 2 8 3 9 0 1 1 0 9 3 8 2 Problem 14: Write a program that will take input n integers into an array A and then m integers into an array B. Now swap all elements between array A and B. Finally show all elements of both array A and B. Input: first line of the input represents the size of array A and then take input all the elements of array A the next line represents the size of array B and then take input all the elements of array B. Sample input Sample output 8 7 8 1 3 2 6 4 3 3 3 2 1 Array A : 3 2 1 Array B : 7 8 1 3 2 6 4 3