C++ simple question, need help =/

INSTRUCTIONS:Given an int variable k that has already been declared, use a while loop to print a single line consisting of 97 asterisks. Use no variables other than k .

Here is what I put in:

1
2
3
4
5
while (k <= 97)
{
cout << "*";
k++;
}


Here is the error I keep getting:

Remarks:
     ⇒     When executed, your code tried to create an excessively
               large file. A common cause for this is an infinite loop.
               Carefully check the condition and the loop body of any loop
               that does output.



I understand that the code I put in is doing this:
1
2
3
4
      *
      *
      *
      *
(97 times).

But how do I make the while loop do this, I need it on a single line;

********
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Demonstrate strtok(). 
#include <iostream> 
#include <cstring> 
 
using namespace std; 

int main() { 
	int k = 0;
	while (k <= 97)
	{
	cout << "*";
	k++;
	}
}


Nothing wrong with your code,bring here the full one.
Apparently it wanted me to declare 0 when it told me it had already been declared. Lol I feel like I am answering philosophy questions the wording is so misleading...
Topic archived. No new replies allowed.