Question: b. Given the following C++ program segment in Figure 1 int a 2, b, x = 1; while (x < 12) b = a
b. Given the following C++ program segment in Figure 1 int a 2, b, x = 1; while (x < 12) b = a + x; cout < < b < < " "; if (x50) cout < < endl; x = x + 2/ Figure 1 A loop that continues to execute endlessly is called an infinite loop. Identify a way to avoid an infinite loop? i. Rewrite this program segment using for loop. (2 marks) (3 marks)
Step by Step Solution
3.37 Rating (153 Votes )
There are 3 Steps involved in it
To rewrite the given C program segment using a for loop and avoid an infinite loo... View full answer
Get step-by-step solutions from verified subject matter experts
