Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

contents

t o p i c

S l
n o

MATRIX
1

Sum of All Matrix Elements

Sum of Matrix Column Elements

Sum of Matrix Diagonal Elements

Spiral Matrix

NUMBER BASED
5
6

Calendar of Any Month


AP Series

Calendar of Any Month

8
9
10

Date Program
Evil Number
Reverse Prime

11

Kaprekar

STRING BASED
13

Palindrome Check

14

Frequency of Each String Character

15

Word Search in String

16

Decoding of String

17

String in Alphabetical Order

P a g e

N o :

18

Number of Vowels and Consonants

19

Word Count

20

Replacing Vowels with *

RECURSION BASED
21

Factorial (Using Recursion)

22

Fibonacci Series (Using Recursion)

23

GCD (Using Recursion)

24
25
26
27

ARRAY BASED

PROGRAM 1
Sum of All Matrix Elements
ALGORITHM:
STEP 1 START
STEP 2 - INPUT a[]
STEP 3 - FROM x =0 to x<5 REPEAT STEP 4
STEP 4 - FROM y =0 to y<5 REPEAT STEP 5
STEP 5 - PRINT (a[x][y]+" "
STEP 6 - FROM x =0 to x<5 REPEAT STEP 7
STEP 7 - FROM y =0 to y<5 REPEAT STEP 8
STEP 8 - Sum=Sum+a[x][y]
STEP 9 - PRINT Sum
STEP10 END

SOLUTION:
import java.io.*;
class MatrixSum
{public static void main(String args[])throws IOException//main function
{ int a[][]=new int[5][5];
BufferedReader aa=new BufferedReader(new InputStreamReader(System.in));
int x,y,z,Sum=0;System.out.println("Enter the array");
for(x=0;x<5;x++)//loop for reading array
{for(y=0;y<5;y++)
{ z=Integer.parseInt(aa.readLine());//accepting array element
a[x][y]=z;}}
System.out.println("Array);
for(x=0;x<5;x++)
{
for(y=0;y<5;y++)

{
System.out.print(a[}
System.out.print("\n}for(x=0;x<5;x++){for(y=0;y<5;y++){Sum=Sum+a[x]
[y];}}System.out.println("}}
v a r i
No.
Name Type
1 aa Buffere2 a int[][]3 x int4 y int5 z int6 Sum main()
o u t p
62 |I S C
C o
m p
u t
rray -");//loop for printing array ][y]+" ");");//loop for printing sum of array elum of Array
elements="+Sum);
b l e d e s c r
MethodDescription
d R e a d e r m a i n ( ) B u f f e r e d R e a d e r
o b j e c t m a i n ( ) i n p u t
a r r a y m a i n ( ) l o o p v a r i a b l
e m a i n ( ) l o o p v a r i a b l e m a i n ( ) i n p u t e l e m e n t m a i
n ( ) S u m o f a l l e l e m e n t s
ut
e
r
S
c
i
ments/displaying sum
i
p
t
i
o

You might also like