2nd project
Class XI
2024-2025
Salt lake Point School
2D array :
Program no:1
Write a program to find if the given matrix is lower triangular matrix or not .A square matrix is said to
be a lower triangular matrix if all the entries above the main diagonal are zero. If it is a lower
triangular matrix then print lower triangle.
Input:
Order: 4
original matrix.......
5 0 0 0
7 6 0 0
1 2 8 0
8 9 5 1
It is a lower triangular matrix.....
Displaying triangle.......
7 6
1 2 8
8 9 5 1
Program no:2
Write a program to find if the given matrix is upper triangular matrix or not .A square matrix is said to
be an upper triangular matrix if all the entries below the main diagonal are zero. If it is an upper
triangular matrix then print upper triangle.
Input:
Order: 4
original matrix.......
2 3 5 9
0 6 7 8
0 0 9 1
0 0 0 4
It is an upper triangular matrix.....
Displaying triangle.......
2 3 5 9
6 7 8
9 1
Question 3:
Write a program to create a magic square matrix when order is an even number and order is an odd
number.
Input:
Order :4
Output......
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
Input:
Order :5
Output......
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
Question 4:
Write a program to display the mirror image of a matrix. Consider the mirror is placed vertically and
horizontally using switch case.
Case 1:
Mirror (when horizontally placed)
Input:
2 7 8
9 1 2
3 4 5
5 6 7
Output:
5 6 7
3 4 5
9 1 2
2 7 8
Case 2:
Mirror (When vertically placed)
Input:
2 7 8
9 1 2
3 4 5
5 6 7
Output:
Displaying......
8 7 2
2 1 9
5 4 3
7 6 5
Program no: 5
Write a program to declare a square matrix A[][] of order (M x M) where ‘M’ must be greater than 3
and less than 10. Allow the user to input integers into this matrix.
Perform the following tasks on the matrix:
(a) Sort the boundary elements in ascending order using any standard sorting technique and
rearrange them in the matrix.
(b) Calculate the sum of both the diagonals.
(c) Display the original matrix, rearranged matrix after sorting and only the diagonal elements of the
rearranged matrix with their sum.
Test your program with the following data and some random data.
Example 1:
Order of the Matrix: 4
Original Matrix......
Displaying matrix.......
3 8 9 0
1 4 3 8
2 9 2 5
1 7 4 2
After sorting the boundary elements:
Displaying matrix.......
0 1 1 2
2 4 3 3
4 9 2 5
7 8 8 9
DIAGONAL ELEMENTS
0 2
4 3
9 2
7 9
SUM OF THE DIAGONAL ELEMENTS = 36
Example 2:
Order of the Matrix: 4
Original Matrix......
Displaying matrix.......
22 88 11 44 77
44 99 11 44 55
22 33 90 23 45
67 12 43 29 80
27 26 43 26 34
After sorting the boundary elements:
Displaying matrix.......
11 22 22 26 26
27 99 11 44 34
43 33 90 23 44
44 12 43 29 45
55 67 77 80 88
DIAGONAL ELEMENTS
11 26
99 44
90
12 29
55 88
SUM OF THE DIAGONAL ELEMENTS = 454
Example 3:
Order of the Matrix: 10
Out of range….
Program no:6
Write a program to display the 90-degree rotation of a matrix. Consider the anticlockwise and
clockwise
Case 1:
Clockwise 90-degree rotation
Input:
original matrix.......
7 8 9 1
5 2 0 2
4 5 3 7
__________________
Matrix after 90 degree clockwise rotation:...
4 5 7
5 2 8
3 0 9
7 2 1
Case 2:
Anti-Clockwise 90-degree rotation
Input:
7 8 9 1
5 2 0 2
4 5 3 7
__________________
after 90 degree anti clockwise rotation:...
1 2 7
9 0 3
8 2 5
7 5 4
Program no:7
Write a program to create a spiral in matrix using Fibonacci series.
Number for row no :5
Number for column no : 4
1st number in the Fibonacci series: 2
2nd number in the Fibonacci series:1
Matrix:
2 1 3 4
521 843 1364 7
322 9349 2207 11
199 5778 3571 18
123 76 47 29
Call by reference (pass object as argument)
Program no:8
An angle may be measured in degrees and minutes. E.g.
A= 70 degrees 35 minutes
and
B = 50 degrees 40 minutes
Now to find
the sum of these two angles:
C= A + B=70 degrees 35 minutes + 50 degrees 40 minutes
=121 degrees 15 minutes (Since 1 degree = 60 minutes)
Define
a class angle
for accepting and calculating the sum of the two angles given. The
description of the class is given as follows:
Class
name angle
Data
members: int deg,min
Member functions:
angle() constructor
void
accept() for
accepting the angles
angle
sumangle(angle, angle) for calculating the sum of the two angles
given and return the sum.
void display() to print sum of angles
Write a program to specify the class angle with all member function and main().
Date programs :
Program 9:
Input consists of month number (MM), the day of the month (DD) and the year (YYYY). Write a
program to calculate and print the corresponding day of the year ( in the range 1 to 366).
Example:
Input: Month 05
Day 03
Year 1996
Output: CORRESPONDING DAY OF THE YEAR IS : 124
( 31 + 29 + 31 + 30 + 3 = 124 )
Program no:10
Write a program to accept 2 dates in the string format dd/mm/yyyy and find the difference in days
between the 2 dates.
Example:
INPUT:
Date 1 : 20/12/2012
Date 2 : 11/02/2013
OUTPUT: Difference = 53 days
The program should include the part for validating the inputs namely the date and the day on
1st January of that year.
Sample:
Program No:
Problem Definition:
(Write Question)
Algorithm:
Step 1: start
Last step should be stop or end.
Program Code:
Paste the source code here (from BlueJ)
Input/Output:
Paste the input/output (for at least 4 times) from terminal window
Variable description:
Name Type Purpose scope
Method description:
Function Name Return Type Argument Name Argument Type purpose
INSTRUCTIONS
1. Entire project must be in printed format.
2. Follow the above pattern given as a sample.
3. Give comment lines for calculation parts
4. First page should be self-profile.
5. Maintain font as Arial and size as 11
Follow all the instructions given in the class.
Last date of second project submission is on 26 th August 2024
Total : 10 programs