Given number is even OR odd if it is even print square of that number or if it is odd print cube of that number.
can anyone write program for this and help me
Answers
Answered by
12
Hey there !
The answer for your question for JAVA (with scanner class) is as follows :-
import java.util.* ;
class abc
{
void main()
{
int n;
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number");
n = sc.nextInt();
if (n%2 ==0)
System.out.println("The number is even. Its square is " + (n*n));
else
System.out.println("The number is odd. Its cube is " + (n*n*n));
}
}
Hope it helps :-)
harindersaini2pcf8vf:
Please mark as brainliest if it really helped...please...please
Similar questions
English,
6 months ago
Hindi,
6 months ago
Math,
1 year ago
Computer Science,
1 year ago
Hindi,
1 year ago