WAP in java to display the series using loop.
1,11,111,1111,11111
Answers
Answer:
well here is it
Explanation:
import java.util.Scanner;
public class Series
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int s = 0, c; // s for terms of series, c for n terms
for (c = 1; c <= 5; c++) // To generate 5 terms
{
s = s * 10 + 1;
System.out.print(s + " ");
} //for ends
}
}
hope it is helpful,
mark it brainliest,
mark it brainliest,follow me for further help
have a good day
Question:-
Write a program to display the following series using loop.
1 11 111 1111...
Program:-
import java.util.*;
class Series
{
public static void main(String s[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the value of n: ");
int n=sc.nextInt(), a=1;
for(int i=1;i<=n;i++,a=a*10+1;)
System.out.print(a+" ");
}
}