Please read the question carefully and select the correct answer
What will be the output of the following program? class WhileExample { public static
void main(String s[]) {int n = 5; while( n > 0) {n--; System.out.println("n = " + n );}}
Answers
Answered by
0
Answer:
Compilation error
Explanation:
First of all this code contains error, in line "public static void main" here M should capital in "Main" and also "String s[]" should be "String[] s" so the correct code is
public static void Main(String[] s)
{
int n = 5;
while( n > 0)
{
n--;
Console.WriteLine("n = " + n );
}
}
And then its output is
n = 4
n = 3
n = 2
n = 1
n = 0
Answered by
1
Answer:-
Given code,
class WhileExample
{
public static void main(String s[])
{
int n = 5;
while( n > 0)
{
n--;
System.out.println("n = " + n );
}
}
}
There is no error in this code.
Output will be,
n=4
n=3
n=2
n=1
n=0
Similar questions
Social Sciences,
4 months ago
Hindi,
4 months ago
Computer Science,
4 months ago
Chemistry,
9 months ago
Physics,
1 year ago