Write a program in Java to print :
1
12
123
1234
12345
50 points (:
Answers
Answered by
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
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
Math,
4 months ago
Math,
8 months ago
English,
8 months ago
English,
10 months ago
Social Sciences,
10 months ago