➻Write a (java) program to print the square of first 10 numbers.
No spam ✘
Answers
Answer:
import java.util.*;
public class Square
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int num;
System.out.print("Enter a number which is integer format: ");
num=sc.nextInt();
System.out.println("The square of "+ num + " is: "+ Math.pow(num, 2));
}
}
Answer:
here is ur answer :
// Java Program to find sum of
// square of first n natural numbers
import java.io.*;
class GFG {
// Return the sum of square of first n natural numbers
static int squaresum(int n)
{
// Iterate i from 1 and n
// finding square of i and add to sum.
int sum = 0;
for (int i = 1; i <= n; i++)
sum += (i * i);
return sum;
}
// Driven Program
public static void main(String args[]) throws IOException
{
int n = 4;
System.out.println(squaresum(n));
}
}
or I think the pic is the answer ..
hope any answer helps u
plz mark as brainliest if you are satisfied with the answer..
have a great day
keep smiling always dear sis