Page 1 of 1

b. Given the following C++ program segment in Figure 1 int a - 2, b, X - 1; while (x <= 12) b = a + 3; cout << b <<""; i

Posted: Sat Feb 19, 2022 3:20 pm
by answerhappygod
B Given The Following C Program Segment In Figure 1 Int A 2 B X 1 While X 12 B A 3 Cout B I 1
B Given The Following C Program Segment In Figure 1 Int A 2 B X 1 While X 12 B A 3 Cout B I 1 (17.7 KiB) Viewed 27 times
b. Given the following C++ program segment in Figure 1 int a - 2, b, X - 1; while (x <= 12) b = a + 3; cout << b <<""; if (x % 5 -- 0) cout << endl; x = x + 2; Figure 1 i. A loop that continues to execute endlessly is called an infinite loop. Identify a way to avoid an infinite loop? (2 marks) ii Rewrite this program segment using for loop. (3 marks)