make a program to display the following output 1, 1, 2, 4, 3,9,4 ,16 5,25 6,36 7,49 8,64
Answers
Answered by
0
Python implementation:
#n is the range of numbers
n = int(input())
for i in range(1,n+1):
print(i,end=',')
if i is n:
print(i*i)
else:
print(i*i,end=',')
Answered by
0
Answer: In Java Programming language
Explanation:This program is valid if you want the output upto 8 and its square only. If you want the output for n numbers, create an int variable and take input and run the loop up to n
public class series
{
public static void main()
{
for(int i=1;i<=8;i++)
System.out.print(i+", "+(i*i)+", ");
}
}
Similar questions