Java Pattern Programs
Write a program in Java to display the following pattern:
1
3 5
7 9 11
13 15 17 19
21 23 25 27 29
Java
Java Nested for Loops
14 Likes
Answer
public class KboatPattern
{
public static void main(String args[]) {
int term = 1;
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(term + " ");
term += 2;
}
System.out.println();
}
}
}
Output
Answered By
6 Likes