ICSE Computer Science Java Programs | IT Developer
IT Developer

Java Programs - Solved 2015 ICSE Computer Science Paper



Share with a Friend

Solved 2015 ICSE Computer Science Paper

Class 10 - ICSE Computer Science Solved Papers

Pattern Program - ICSE 2015 Computer Science

Write two separate programs to generate the following patterns using iteration (loop) statements:
(a)

*
*#
*#*
*#*#
*#*#*

(b)

5 4 3 2 1
5 4 3 2
5 4 3
5 4
5

Pattern Program - 1

class Pattern1{ public static void main(String args[]){ for(int i = 1; i <= 5; i++){ char ch = '*'; for(int j = 1; j <= i; j++){ System.out.print(ch); if(ch == '*') ch = '#'; else ch = '*'; } System.out.println(); } } }

Output

 
 OUTPUT : 
*
*#
*#*
*#*#
*#*#*
 

Pattern Program - 2

class Pattern2{ public static void main(String args[]){ for(int i = 1; i <= 5; i++){ for(int j = 5; j >= i; j--) System.out.print(j); System.out.println(); } } }

Output

 
 OUTPUT : 
54321
5432
543
54
5