(4 marks) b. Given the following C++ program segment in Figure 1 int a - 2, b, X - 11 while (x - 12) b- + x cout << b <<
Posted: Sat Feb 19, 2022 3:20 pm
(4 marks) b. Given the following C++ program segment in Figure 1 int a - 2, b, X - 11 while (x - 12) b- + x cout << b << "; if (x 50) 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? (2 marks) Rewrite this program segment using for loop (3 marks) .