Oh! He's got an aptitude for it, trust me! Maybe a bit too much enthusiasm, atm, but that will work itself out. (and just my opinion anywho)
I would do it like this:
Code:
#include <stdio.h>
#include <limits.h>
#include <time.h>
int main() {
clock_t start, stop;
long int i, shortMax;
char snum[11];
double elapsed;
printf("\n\n Goal Number is: %ld", LONG_MAX);
start=clock();
shortMax = LONG_MAX-3;
for(i=0;i<LONG_MAX;i++) {
ltoa(i, snum, 10); //maximum of 33 bytes for Turbo C
if(i>shortMax)
printf("\n%s",snum);
}
stop=clock();
elapsed=(double) stop-start;
printf("Elapsed time was: %lf: ", elapsed/CLK_TCK); //replace with CLOCKS_PER_SEC for VC
printf("\n\n\t\t\t press enter when ready");
i = getchar();
return 0;
}
I have my misgivings about the need for ALL these numbers, but this is how I'd generate all those numbers, as strings, if I needed to.
The if statement inside the for loop, prevents Turbo C from smartly skipping over the entire for loop, in zero time. You'll want to add your output etc., and remove it, of course.
I'm looking at this from a "you'll only need to do this just one time, so fast is great, but absolute blazing speed is not required", point of view.
One of my Sudoku analyzer programs uses 81 nested for loops
<< let us pause for those so inclined to recover from their fainting spell >>
So I'm not against nested loops. I just wouldn't use them, for this.