Square Number Series Program in Java

In this tutorial you will learn about the Square Number Series Program in Java and its application with practical example.

In this tutorial, we will learn to create a Square Number Series Program in Java  using java programming.

Prerequisites

Before starting with this tutorial, we assume that you are best aware of the following Java programming concepts:

  • Java Operators.
  • Basic Input and Output function in Java.
  • Class and Object in Java.
  • Basic Java programming.
  • If-else statements in Java.
  • For loop in Java.

Square of a number ?

Square a number is when we simply multiply number by itself.

Example: “Square of 2” = 2 ×2 = 4

Square Number Series Program in Java

In this program we will square of number till the size of N  using for loop. We would first declared and initialized the required variables. Next, we will find square of numbers .Lets have a look at the code.

Output

In the above program, we have first declared and initialized a set variables required in the program.

  • number= it will hold given number.
  • i = for iteration
  • sqr = it will hold square of values.

After declaring variables we initiate values taking value from user.

User entered a number till the number we looped using for loop and  within the loop we will find square of numbers.

as you can loop will till number and within the loop we will find squares of number

Now we use for loop to get the desired output as shown in  image.

And finally we print the result that is square of number till the number inputted by user.

In this tutorial we have learn about the Square Number Series Program in Java and its application with practical example. I hope you will like this tutorial.