Q15 write a vb program to print the series like 1 4 9 25… up to n terms.

The code is as follows:

Module Module1
Dim n As Integer
Dim i As Integer

Sub Main()

System.Console.Write("Enter the value of n=")
n = System.Console.ReadLine()
For i = 1 To n
System.Console.Write(" " & (i * i))



End Sub

End Module

In this program we have declared n,I variables . here we have used the Console.Write function to show message and Console.ReadLine function to get input and assign it into the variable n. after that we have used the for loop and have a condition i=1 To n means loop will be continued to the nth value when condition will be false then loop will terminate. Here we have used i*i to get the square value of i. The output is as follows: