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 [Link].*;
class MatrixSum
{public static void main(String args[])throws IOException//main function
{ int a[][]=new int[5][5];
BufferedReader aa=new BufferedReader(new InputStreamReader([Link]));
int x,y,z,Sum=0;[Link]("Enter the array");
for(x=0;x<5;x++)//loop for reading array
{for(y=0;y<5;y++)
{ z=[Link]([Link]());//accepting array element
a[x][y]=z;}}
[Link]("Array);
for(x=0;x<5;x++)
{
for(y=0;y<5;y++)
{
[Link](a[}
[Link]("\n}for(x=0;x<5;x++){for(y=0;y<5;y++){Sum=Sum+a[x]
[y];}}[Link]("}}
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