- 2 Consider The Following Program Include Iostream Using Namespace Std J Int Main Int Len Cout Enter A 1 (47.17 KiB) Viewed 53 times
2. Consider the following program: #include using namespace std; j++) int main() { } int len; cout<<"Enter a
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
2. Consider the following program: #include using namespace std; j++) int main() { } int len; cout<<"Enter a
2. Consider the following program: #include <iostream> using namespace std; j++) int main() { } int len; cout<<"Enter a number: ; cin >> len; for (int i = 0; i < len; i++) { } for (int j =i+1; j < len; { cout << " "; } cout << "#" << endl; return(0); In a brief, simple English sentence, state what this program does (e.g. "It prints a picture of an aqueduct."). Again, figure this out by hand. 3. Copy the program in problem 2 and change it so that for any input number, the changed program produces exactly the same output as the original, but the changed program uses a while loop instead of a for loop for the inner loop. 4. Copy the program you wrote for problem 3 and change it so that for any input number, it produces exactly the same output as the original, but uses a do-while loop instead of a for loop for the outer loop. Be careful! (Hint: How does it behave if len is not positive?) You may need to add a little additional code to make sure the program behaves identically to the program in problem 3.