How many error(s) the following code has –.
class Q5 { public static void main(String args[ ] )
{ if(n>120) { int m = Math.pow(n,2) System.out.println(“Square=”+n);
else int m = Math.pow(3,n); System.out.println(“Cube=”+ m ); } } }
Answers
Answered by
0
Answer:
isme following codes kaha likha rahe he or ache se likhiye question
Answered by
0
class Q5
{
public static void main(String args[ ] )
{
if(n>120)
{
int m = Math.pow(n,2)
System.out.println(“Square=”+n);
}
else
{
int m = Math.pow(3,n);
System.out.println(“Cube=”+m);
}
}
}
Error 1: Syntax error in line [int m = Math.pow(n,2)]
there must be a semi-colon at last.
Error 2: Logical error in line [System.out.println(“Square=”+n);]
The variable should be m not n because this value will be stored by variable m and n is for running the if else...
Similar questions
Social Sciences,
3 months ago
Math,
3 months ago
Chemistry,
3 months ago
Math,
6 months ago
English,
6 months ago
Political Science,
11 months ago
Political Science,
11 months ago
Sociology,
11 months ago