W.A.P. to accept a number. If the number is even, calculate & print its square, print its cube.
Answers
Answered by
0
Answer:
The program is written in java
Explanation:
import java.util.Scanner;
class answer{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number");
int num = sc.nextInt();
if(num%2==0)
System.out.println((num*num));
else
System.out.println((num*num*num));
}
}
Similar questions