- Home
- Chapter 1 - Object Oriented Programming Concepts
- Object Oriented Programming Concepts
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 2 - Introduction to Java
- Introduction to Java
- Multiple Choice Questions
- Assignment Questions
- Chapter 3 - Values and Data Types
- Values and Data Types
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 4 - Operators in Java
- Operators in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 5 - User-Defined Methods
- User-Defined Methods
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 6 - Input in Java
- Input in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 7 - Mathematical Library Methods
- Mathematical Library Methods
- Multiple Choice Questions
- Assignment Questions
- Chapter 8 - Conditional Constructs in Java
- Conditional Constructs in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 9 - Iterative Constructs in Java
- Iterative Constructs in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions and Programs
- Chapter 10 - Nested for loops
- Nested for loops
- Assignment Questions and Programs
- Chapter 11 - Constructors
- Constructors
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 12 - Library Classes
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 13 - Encapsulation and Inheritance
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 14 - Arrays
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 15 - String Handling
- Library Classes
- Multiple Choice Questions
- Assignment Questions
Nested for Loops
Chapter 10
Nested for Loops
Class 10 - Logix Kips ICSE Computer Applications with BlueJ
![]() Share with a Friend |
Assignment Questions and Programs
1. Write a program to generate the following output.
@
@ #
@ # @
@ # @ #
@ # @ # @
2 (i). Write a program in Java to display the following patterns.
1
2 3
4 5 6
7 8 9 10
11 12 13 14 152 (ii). Write a program in Java to display the following patterns.
1 * * * *
* 2 * * *
* * 3 * *
* * * 4 *
* * * * 5
2 (iii). Write a program in Java to display the following patterns.
#
* *
# # #
* * * *
# # # # #
2 (iv). Write a program in Java to display the following patterns.
1 * * * *
2 2 * * *
3 3 3 * *
4 4 4 4 *
5 5 5 5 5
2 (v). Write a program in Java to display the following patterns.
$ $ $ $ 5
$ $ $ 4
$ $ 3
$ 2
1
2 (vi). Write a program in Java to display the following patterns.
A B C D E
A B C D
A B C
A B
A
2 (vii). Write a program in Java to display the following patterns.
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
2 (viii). Write a program in Java to display the following patterns.
I
I C
I C S
I CI S E
2 (ix). Write a program in Java to display the following patterns.
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
2 (x). Write a program in Java to display the following patterns.
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
3 (i). Distinguish between the following:
break statement and labelled break statement
3 (ii). Distinguish between the following:
continue statement and labelled continue statement
4. Write a program to print the series given below.
8 88 888 8888 88888 888888
5 (i). What will be the value of sum after each of the following nested loops is executed?
int sum = 0;
for (int i = 0; i <= 10; i++)
for (int j = 0; j <= 10; j++)
sum += i;
5 (ii). What will be the value of sum after each of the following nested loops is executed?
int sum = 0;
for (int i = 1; i <= 3; i++)
for (int j = 1; j <= 3; j++)
sum = sum + (i + j);
6. Write a program to generate a triangle or an inverted triangle till n terms based upon the user's choice of triangle to be displayed.
Example 1
Input:
Type 1 for a triangle and type 2 for an inverted triangle
1
Enter the number of terms
5
Output:1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Example 2
Input:
Type 1 for a triangle and type 2 for an inverted triangle
2
Enter the number of terms
6
Output:6 6 6 6 6 6
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
7. Write a program to compute and display factorials of numbers between p and q where p > 0, q > 0, and p > q.
8. Write a program to determine if an entered number is a Happy Number. A happy number is defined by the following process:
Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number is equal to 1.
For example, 19 is a happy number, as per the following calculation:
12 + 92 = 82,
82 + 22 = 68,
62 + 82 = 100,
12 + 02 + 02 = 19. Write a menu driven program that prompts the user to select one of the four triangle patterns (a, b, c, or d). The program then accepts number of rows and prints the selected pattern as shown below:
Enter the size : 8
(a)
#
# #
# # #
# # # #
# # # # #
# # # # # #
# # # # # # #
# # # # # # # #
(b)
# # # # # # # #
# # # # # # #
# # # # # #
# # # # #
# # # #
# # #
# #
#
(c)
# # # # # # # #
# # # # # # #
# # # # # #
# # # # #
# # # #
# # #
# #
#
(d)
#
# #
# # #
# # # #
# # # # #
# # # # # #
# # # # # # #
# # # # # # # #10. Write a menu driven program that prompts the user to select one of the four triangle patterns (a, b, c or d). The program then accepts number of rows and prints the selected pattern as shown below:
Enter the size: 8
(a)
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
(b)
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
(c)
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
(d)
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
111. Write a program that computes sin x and cos x by using the following power series:
sin x = x - x3/3! + x5/5! - x7/7! + ......
cos x = 1 - x2/2! + x4/4! - x6/6! + ......
