SlideShare a Scribd company logo
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 (17)

PPT
vlsi training in chandigarh
matrixphagwara
 
PDF
Fy secondsemester2016
Ankit Dubey
 
PDF
Fy secondsemester2016
Ankit Dubey
 
DOCX
Taller número 1 de informática ll
ramivides
 
PDF
Epc assignment
Hồ Lợi
 
PDF
PS3
Iman Taghavi
 
PDF
C Programming Lab manual 18CPL17
manjurkts
 
PPT
03 Operators and expressions
maznabili
 
PPTX
Ch8 Arrays
SzeChingChen
 
PDF
Chapter 3 branching v4
Sunarto Quek
 
PPTX
Array & Exception Handling in C# (CSharp)
Sohanur63
 
PDF
Exercise2 java
NguynMinh294
 
DOCX
C quiz
hardeep01
 
PDF
Introduction to computer_lec_04
Ramadan Babers, PhD
 
PPTX
Basic Programming of c++
MMAbdullah17
 
PDF
Python - Control Structures
LasithNiro
 
DOC
Ques c++ minhnd
Congdat Le
 
vlsi training in chandigarh
matrixphagwara
 
Fy secondsemester2016
Ankit Dubey
 
Fy secondsemester2016
Ankit Dubey
 
Taller número 1 de informática ll
ramivides
 
Epc assignment
Hồ Lợi
 
C Programming Lab manual 18CPL17
manjurkts
 
03 Operators and expressions
maznabili
 
Ch8 Arrays
SzeChingChen
 
Chapter 3 branching v4
Sunarto Quek
 
Array & Exception Handling in C# (CSharp)
Sohanur63
 
Exercise2 java
NguynMinh294
 
C quiz
hardeep01
 
Introduction to computer_lec_04
Ramadan Babers, PhD
 
Basic Programming of c++
MMAbdullah17
 
Python - Control Structures
LasithNiro
 
Ques c++ minhnd
Congdat Le
 

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

PDF
programs on arrays.pdf
sowmya koneru
 
PPTX
Csci101 lect07 algorithms_ii
Elsayed Hemayed
 
PPTX
lecture 2.2.2 2D array.pptx IUGLFHLHFJFY
gargh4711
 
PDF
SPL 11.1 | Problems on Loop , Nested Loop
Mohammad Imam Hossain
 
PDF
C Programming Example
PRATHAMESH DESHPANDE
 
PDF
Mmt 001
sujatam8
 
PDF
C Programming lab
Vikram Nandini
 
PDF
Array sheet
Mahmoud Abuelmagd
 
PPTX
C programming codes for the class assignment
Zenith SVG
 
PDF
09 a1ec01 c programming and data structures
jntuworld
 
PDF
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
 
PDF
Data Structure using C
Bilal Mirza
 
PPTX
Ch-11-Arrays.ppt-1.pptx eurhrbdhdbdhrhdhdh
zakiking612
 
PPT
358 33 powerpoint-slides_5-arrays_chapter-5
sumitbardhan
 
PPTX
Arrays 2d Arrays 2d Arrays 2d Arrrays 2d
LakshayBhardwaj39
 
PPTX
C Programming Language Part 8
Rumman Ansari
 
PPTX
Mcs011 solved assignment by divya singh
DIVYA SINGH
 
PPTX
Arrays.pptx
saimasiddique11
 
PDF
C programming exercises and solutions
Rumman Ansari
 
DOC
Basic c programs updated on 31.8.2020
vrgokila
 
programs on arrays.pdf
sowmya koneru
 
Csci101 lect07 algorithms_ii
Elsayed Hemayed
 
lecture 2.2.2 2D array.pptx IUGLFHLHFJFY
gargh4711
 
SPL 11.1 | Problems on Loop , Nested Loop
Mohammad Imam Hossain
 
C Programming Example
PRATHAMESH DESHPANDE
 
Mmt 001
sujatam8
 
C Programming lab
Vikram Nandini
 
Array sheet
Mahmoud Abuelmagd
 
C programming codes for the class assignment
Zenith SVG
 
09 a1ec01 c programming and data structures
jntuworld
 
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
 
Data Structure using C
Bilal Mirza
 
Ch-11-Arrays.ppt-1.pptx eurhrbdhdbdhrhdhdh
zakiking612
 
358 33 powerpoint-slides_5-arrays_chapter-5
sumitbardhan
 
Arrays 2d Arrays 2d Arrays 2d Arrrays 2d
LakshayBhardwaj39
 
C Programming Language Part 8
Rumman Ansari
 
Mcs011 solved assignment by divya singh
DIVYA SINGH
 
Arrays.pptx
saimasiddique11
 
C programming exercises and solutions
Rumman Ansari
 
Basic c programs updated on 31.8.2020
vrgokila
 
Ad

More from Mohammad Imam Hossain (20)

PDF
DS & Algo 6 - Offline Assignment 6
Mohammad Imam Hossain
 
PDF
DS & Algo 6 - Dynamic Programming
Mohammad Imam Hossain
 
PDF
DS & Algo 5 - Disjoint Set and MST
Mohammad Imam Hossain
 
PDF
DS & Algo 4 - Graph and Shortest Path Search
Mohammad Imam Hossain
 
PDF
DS & Algo 3 - Offline Assignment 3
Mohammad Imam Hossain
 
PDF
DS & Algo 3 - Divide and Conquer
Mohammad Imam Hossain
 
PDF
DS & Algo 2 - Offline Assignment 2
Mohammad Imam Hossain
 
PDF
DS & Algo 2 - Recursion
Mohammad Imam Hossain
 
PDF
DS & Algo 1 - Offline Assignment 1
Mohammad Imam Hossain
 
PDF
DS & Algo 1 - C++ and STL Introduction
Mohammad Imam Hossain
 
PDF
DBMS 1 | Introduction to DBMS
Mohammad Imam Hossain
 
PDF
DBMS 10 | Database Transactions
Mohammad Imam Hossain
 
PDF
DBMS 3 | ER Diagram to Relational Schema
Mohammad Imam Hossain
 
PDF
DBMS 2 | Entity Relationship Model
Mohammad Imam Hossain
 
PDF
DBMS 7 | Relational Query Language
Mohammad Imam Hossain
 
PDF
DBMS 4 | MySQL - DDL & DML Commands
Mohammad Imam Hossain
 
PDF
DBMS 5 | MySQL Practice List - HR Schema
Mohammad Imam Hossain
 
PDF
TOC 10 | Turing Machine
Mohammad Imam Hossain
 
PDF
TOC 9 | Pushdown Automata
Mohammad Imam Hossain
 
PDF
TOC 8 | Derivation, Parse Tree & Ambiguity Check
Mohammad Imam Hossain
 
DS & Algo 6 - Offline Assignment 6
Mohammad Imam Hossain
 
DS & Algo 6 - Dynamic Programming
Mohammad Imam Hossain
 
DS & Algo 5 - Disjoint Set and MST
Mohammad Imam Hossain
 
DS & Algo 4 - Graph and Shortest Path Search
Mohammad Imam Hossain
 
DS & Algo 3 - Offline Assignment 3
Mohammad Imam Hossain
 
DS & Algo 3 - Divide and Conquer
Mohammad Imam Hossain
 
DS & Algo 2 - Offline Assignment 2
Mohammad Imam Hossain
 
DS & Algo 2 - Recursion
Mohammad Imam Hossain
 
DS & Algo 1 - Offline Assignment 1
Mohammad Imam Hossain
 
DS & Algo 1 - C++ and STL Introduction
Mohammad Imam Hossain
 
DBMS 1 | Introduction to DBMS
Mohammad Imam Hossain
 
DBMS 10 | Database Transactions
Mohammad Imam Hossain
 
DBMS 3 | ER Diagram to Relational Schema
Mohammad Imam Hossain
 
DBMS 2 | Entity Relationship Model
Mohammad Imam Hossain
 
DBMS 7 | Relational Query Language
Mohammad Imam Hossain
 
DBMS 4 | MySQL - DDL & DML Commands
Mohammad Imam Hossain
 
DBMS 5 | MySQL Practice List - HR Schema
Mohammad Imam Hossain
 
TOC 10 | Turing Machine
Mohammad Imam Hossain
 
TOC 9 | Pushdown Automata
Mohammad Imam Hossain
 
TOC 8 | Derivation, Parse Tree & Ambiguity Check
Mohammad Imam Hossain
 
Ad

Recently uploaded (20)

PPTX
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
How to Handle Salesperson Commision in Odoo 18 Sales
Celine George
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
community health nursing question paper 2.pdf
Prince kumar
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
MENINGITIS: NURSING MANAGEMENT, BACTERIAL MENINGITIS, VIRAL MENINGITIS.pptx
PRADEEP ABOTHU
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 

SPL 12.1 | Multi Dimensional(Two) Array Practice Problems

  • 1. Mohammad Imam Hossain, Lecturer, dept. of CSE, UIU. Email: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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: [email protected] 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