Write a program in java to display the pattern like right angle triangle with a number.
If given n = 4 then,
The pattern like :
1 12 123 1234
If n=5 then,
The pattern like :
1 12
123 1234
12345
Answers
Answered by
3
1)
#include <stdio.h>
int main() {
int i, space, rows, k = 0; printf("Enter the number of rows
scanf("%d", &rows);
for (i = 1; i <= rows; ++i, k = for (space = 1; space <= rows printf(" ");
} while (k != 2 * i - 1) { printf("* ");
++k;
} printf("\n");
} return 0;
}
2) see in attachment
Attachments:
Answered by
0
Easiest program:
package com.company;
public class Main {
public static void main(String[] args) {
int s = 0;
for (int i = 1; i <= 5 ; i++) {
s = s*10+i;
System.out.println(s);
}
}
}
Output:
1
12
123
1234
12345
Similar questions