Computer Science, asked by chandragupta49, 5 months ago

Write a programe to print squares of numbers 1 to 5


Hey guys answer quickly please

extra 2 points........​

Answers

Answered by anindyaadhikari13
5

Required Answer:-

Question:

  • Write a program to print squares of numbers from 1 to 5.

Solution:

This is an easy program. Here is the code.

It's written in Java.

public class Squares {

public static void main(String[] args) {

System.out.println("Squares of numbers from 1 to 5 are as follows...");

for(int i=1;i<=5;i++)

System.out.print(i*i+" ");

}

}

It's written in Python.

print("Squares of numbers from 1 to 5 are as follows..")

for i in range(1,6):

print(i**2,end=" ")

Output is attached.

Attachments:
Answered by BrainlyProgrammer
3

Question:-

  • Write a programe to print squares of numbers 1 to 5

Answer:-

•Java Code:-

package Coder;

public class Square

{

public static void main(String ar[])

{

for(I=1;I<=5;I++)

System.out.println("Square of "+I+" is "+(Math.pow(I, 2)));

}

}

•Python Code:-

# Code written by:-

# @swetank232894

for I in range(1,6,1):

print("Square of ",I," is ",(I**2))

•Output attached

Attachments:
Similar questions