Computer Applications
Write a program to display the given pattern:
1 1 1 1 1
3 3 3 3
5 5 5
7 7
9
Java
Java Nested for Loops
23 Likes
Answer
public class KboatPattern
{
public static void main(String args[]) {
for (int i = 5, term = 1; i >= 0; i--, term += 2) {
for (int j = 1; j <= i; j++) {
System.out.print(term + " ");
}
System.out.println();
}
}
}
Variable Description Table
Program Explanation
Output

Answered By
12 Likes
Related Questions
The equivalent resistance of series and parallel connections of two resistances are given by the formula:
(a) R1 = r1 + r2 (Series)
(b) R2 = (r1 * r2) / (r1 + r2) (Parallel)
Using a switch case statement, write a program to enter the value of r1 and r2. Calculate and display the equivalent resistances accordingly.
Write a program to display the first ten terms of the series:
5, 10, 17, --------------
Write a program to find the sum of first 20 terms of the series:
S = (2/3) + (4/5) + (8/7) + (16/9) + ----------
Write a program to display the given pattern:
3
5 6
8 9 10
12 13 14 15