#include <windows.h>

int main()


 {
          int i;
          int y=6;
          int x=9;
          gotoxy(x,y);
//gotoxy(x,y) must be the coordinate that the number lies in.
          for(i=0;i>1;i++){
                            printf("%d",i);
                            }

          getch();
          }
int gotoxy(int x,int y)
{COORD coord = {x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}

//how to make this program that the output is a number
that counts up to infinite (or we say just like a timer but there's no minute just all whole number counting up ) using for loop ? and when the number changes it also change in color !
and the color of a number is according to the color attribute of console output.

I just need help because i'm a newbie.

Recommended Answers

All 2 Replies

Your for loop on line 12 will not do anything, and you will continue with line 16. i = 0, and then look at the condition i > 1 to find out why.

As for infinity: very simply said: a computer is just a number of switches and so are not infinite; ergo, you cannot express infinity with it.

Counting to infinity is not possible, with a computer or not, unless you are Chuck Norris.

To use the printf( ), you'll need to include <cstdio>.

You'll need to either write the prototype for your gotxy(), or move the funtion to be before main().

It looks a little more fun if you put the gotoxy inside the loop, and change x and y.

#include <windows.h>
#include <cstdio>

void gotoxy(int x,int y);

int main()


{
    int i;
    int y=6;
    int x=9;
    gotoxy(x,y);
    //gotoxy(x,y) must be the coordinate that the number lies in.
    for(i=0;i<10;i++)
    {
        gotoxy(x,y);
        printf("%d",i);
        x++;
        y++;
    }


}
void  gotoxy(int x,int y)
{
    COORD coord = {x,y};
        SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.