Dremendo Tag Line

Print the number series 1 4 9 using for loop in Java

for Loop - Question 4

In this question, we will see how to print the number series 1 4 9... in Java programming using for loop. To know more about for loop click on the for loop lesson.

Q4) Write a program in Java to print the number series given below using for loop.

1 4 9 16 25 36 49 64 81 100

Program

public class Q4
{
    public static void main(String args[])
    {
        int i;
        for(i=1; i<=10; i=i+1)
        {
            System.out.print(i*i + " ");
        }
    }
}

Output

1 4 9 16 25 36 49 64 81 100
video-poster