Thursday 16 February 2017

Square and Cube of a given number

Q : Write a program to calculate of square and cube of a given number ?

Solution :

class squarecube
{
void get_num(int n)
{
int i;
for(i=1;i<=n;i++)
{
System.out.println("Square of " + i + " is " +(i*i) +
" , Cube is " + (i*i*i));
}
}
}

No comments:

Post a Comment