Answer to Question #319260 in C++ for karabo

Question #319260

Rewrite the following for-loop as a pre-test while-loop. (6)

for x = 1 to 10

for y = 10 to x

if y MOD 2 = 0 then

display "*"

else

display "#"

endif

display " " ~newline


1
Expert's answer
2022-03-29T11:41:16-0400
#include <iostream>
using namespace std;

int main()
{
	int x = 1;
	int y = 10;

	while (x <= 10)
	{
		x++;

		while (y >= x)
		{
			y--;

			#if y % 2 == 0
			{
				cout << "*";
			}

			#else
			{
				cout << "#";
			}

			#endif
			{
				cout << " " << '\n';
			}

			break;
		}
	}

	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog