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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!