Question: Find and correct the errors in the segment code given below. class whileLoopDemo { public static void main(String args[]) { int x = 1, sum
Find and correct the errors in the segment code given below.
class whileLoopDemo {
public static void main(String args[])
{
int x = 1, sum = 0;
// Exit when x becomes greater than 4
while (x <= 10 {
// summing up x
sum = sum + x;
// Increment the value of x for
// next iteration
x++;
}
System.out.println("Summation: " + sum);
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
