Given an int variable n that has already been declared and initialized to a positive value, and another int variable j that has already been declared, use a while loop to print a single line consisting of n asterisks. Thus if n contains 5, five asterisks will be printed. Use no variables other than n and j.
.
.
Click on the title for the solution
.
.
j = 1;
while (j<=n)
{
cout << "*";
j++;
}
.
Click on the title for the solution
.
.
This is the answer:
:
j = 1;
while (j<=n)
{
cout << "*";
j++;
}
Comments
Post a Comment