Computer Science, asked by Anonymous, 8 months ago

Write a program in Java to print :

1
12
123
1234
12345

50 points (:​

Answers

Answered by HariesRam
10

Answer:

import java.util.Scanner;

public class Series

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the number of terms: ");

int n = sc.nextInt();

int s = 0, c; // s for terms of series, c for counter to generate n terms

for (c = 1; c <= n; c++) {

s = s * 10 + c;

System.out.print(s + " ");

}

}

}

Answered by Anonymous
4

Answer:

Print Series 1, 12, 123, 1234, …………n in Java.

1) Public class Series.

2)public static void main(String args[])

3)int n = sc.nextInt();

int n = sc.nextInt();int s = 0, c; // s for 4) terms of series, c for counter to generate n terms.

5)for (c = 1; c <= n; c++) {

Similar questions