diff --git a/pretext/Control_Structures/for_loop.ptx b/pretext/Control_Structures/for_loop.ptx index 1c70c23..69eb92a 100644 --- a/pretext/Control_Structures/for_loop.ptx +++ b/pretext/Control_Structures/for_loop.ptx @@ -111,6 +111,47 @@ int main() { + + + +

+ Construct a C++ program that uses a for loop to print the squares of the numbers + 0 through 4, each followed by a space. Drag the blocks into the correct order on the right. +

+
+ + + #include <iostream> + using namespace std; + + + + int main() { + + + + + for (int i = 0; i < 5; i++) { + + + for (int i = 0; i < 5; i--) { + + + + + cout << i*i << " "; + + + + } + + + + return 0; + } + + +
\ No newline at end of file