English

Write the program in Java to display the first ten terms of the following series: 1, 11, 111, 1111, ................... - Computer Applications

Advertisements
Advertisements

Question

Write the program in Java to display the first ten terms of the following series:

1, 11, 111, 1111, ...................

Answer in Brief

Solution

public class Q1d
{public static void main(String args[])
{ int s = 1;
System.out.print(s + ","); 
for (int i = 1; i < 10; i++)
{s = (s * 10) + 1;
System.out.print(s + ",");
}}}
shaalaa.com
  Is there an error in this question or solution?
Chapter 1.09: Iterative Constructs in Java - EXERCISES [Page 124]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.09 Iterative Constructs in Java
EXERCISES | Q VI. 1. (d) | Page 124
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×