2. Find the error in each of the following. (Note: There may be more than one error a. The following code should print whether a given integer is odd or even: switch (value % 2) { case 0: puts ("Even integer"); case 1: puts ("Odd integer"); b. The following code should output the even integers from 2 to 100: counter = 2; Do { if (counter % 2 == 0) {I printf ("%u%n", counter); counter += 2; } While (counter < 100);

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter14: Exception Handling
Section: Chapter Questions
Problem 11SA
icon
Related questions
Question
2. Find the error in each of the following. (Note: There may be more than one error.)
a. The following code should print whether a given integer is odd or even:
switch (value % 2)
case 0:
puts ("Even integer");
case 1:
puts ("Odd integer");
b. The following code should output the even integers from 2 to 100:
counter = 2;
Do {
if (counter % 2 ==
printf("%u%n", counter);
0) { I
counter += 2;
} While (counter < 100);
Transcribed Image Text:2. Find the error in each of the following. (Note: There may be more than one error.) a. The following code should print whether a given integer is odd or even: switch (value % 2) case 0: puts ("Even integer"); case 1: puts ("Odd integer"); b. The following code should output the even integers from 2 to 100: counter = 2; Do { if (counter % 2 == printf("%u%n", counter); 0) { I counter += 2; } While (counter < 100);
Expert Solution
steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Literals
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning