Problem

Playing CompilerFind the errors in the following statements. If a statement has no errors,...

Playing Compiler

Find the errors in the following statements. If a statement has no errors, then say so. If a statement contains errors, correct them. In each case describe the action of the loop.

a. for (int i = 1; i < = 10; i++)   {     i = i − 1   }


b. int j = 7;   while (j > 1)   {     system.out.println (“again”);     j = j % 2   }


c. intj = 1;   while (j = 1)   {     System.out.print(“try again”);   }


d. for (int k =1, k == 20; k+ +) {}


e. for (float h = 0.0; h<5.0; h = h + .01)     System.out.println(h);


   f. for (double h = 0.0; h<5.0; h = h + .01) {     System.out.println(h);   }


g. do   {     int k = 3;     System.out.print(k);   } while (k != 3);


h. int k = 3; do   {     System.out.print(k);   } while (k != 3);


i. do   {     System.out.println("This looks correct")   } while {true};


j. while (true)   {     int x = x + 1;   }


k. int m = 2;   while (m > 0) do   {     m = m − 1;   };


   l. int m = 2;     while (m > 0) do   {     m = m − 1;     System.out.println(m);   };


m. int m = 2;   while (m > 0)   {     m = m − 1;     System.out.println(m);   } while (false);


n. int k;   for (k = 0; k = 1; k+ +)   {     System.out.print(k = 1);   }


o. int x = 7;   do     (System.out.println(x); x--)   while {x<2};


p. for (int k = 0; k<100; k = ++k)     System.out.println(k)


q. for (int k = 0; k<100; k = ++k)     System.out.println(k);


r. for (int k = 0; k<100; k = k+ +)     System.out.println(k);


s. for (int k = 0; k<100; k = ++k)     System.out.println(k++);


t. for (int k = 0; k<100; k = ++k)     System.out.println(--k);

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT