Question:

How to give an instruction to computer to start counting numbers ?

by Guest44713  |  earlier

0 LIKES UnLike

I want to write a program that tells computer to start counting (en umerating 0,1,2,3,4,5,6,7,8,9,10,....,n) and saving it into a file.

 Tags:

   Report

3 ANSWERS


  1. Sure you can even do this is DOS.

    for /L %n IN (1,1,10000) DO echo %n >> myfile.txt

    Of course you could use the set command

    set n=1

    echo %n% > myfile.txt

    set /A n=%n% + 1

    echo %n% >> myfile.txt

    Of course, C might be easier but you'd have to compile it.

    int main()

    {

    FILE *fptr;

    fptr = fopen("myfile.txt", "rw");

    if (fptr != NULL) {

    for (n = 1; n < 10000; n++) {

    fptr.write(n);

    }

    fclose(fptr);

    }

    }


  2. The algorthm is x= 0

    dispa'lay

    x= o+1 = s

    diplay

    x=(s++)

    diplay

    x + (s++)

    Dispay

    And so on

  3. I don't think that would be a good idea. Since there are an infinite number of numbers your computer would soon fill up all it's available hard drive. This would be an infinite loop and your computer would probably just crash.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.