0

I want to print each number from 1 to 10 on the cleared screen with some time between them. I tried this code:

#include <iostream>
using namespace std;

int main()
{
  for(int i = 1; i <= 10; i++)
  {
    cout << i;
    system("cls");
    for(int j = 1; j <= 10000000; j++)
        continue;
  }
  return 0;
}

But it doesn't work as intended, instead:

enter image description here

How to get what I actually wish?

halfer
  • 19,824
  • 17
  • 99
  • 186
VIVID
  • 555
  • 6
  • 14
  • should be `clear` not `cls` – sebastian Jul 23 '20 at 08:30
  • @sebastian Well, now those `not found`'s disappeared, but still I get `12345678910` on the same screen... – VIVID Jul 23 '20 at 08:33
  • I want something like *seconds* in watch – VIVID Jul 23 '20 at 08:34
  • Does this answer your question regarding time? https://stackoverflow.com/questions/158585/how-do-you-add-a-timed-delay-to-a-c-program/158614 – Aziuth Jul 23 '20 at 08:35
  • Note that you try to clear the screen as soon as you display `i`.I am surprised you can see anything. – Damien Jul 23 '20 at 08:37
  • Also: https://stackoverflow.com/questions/6486289/how-can-i-clear-console in regard to clearing the screen. You should really learn how to search things on the internet. – Aziuth Jul 23 '20 at 08:38

0 Answers0