N
Nick Keighley
could any one solve the following C program. If any one knows the
answer please post it
A C function that will print 1 to N one per each line on the
stdout , where N is a int parameter to the function. The function
should not
use while, for, do-while loops, goto statement, recursion, and switch
statement.
how about something like this
void printn (int n)
{
char s[] = " 1\n 2\n 3\n 4\n 5\n 6\n 7\n 8\n 9\n10\n11\n\n";
printf ("%0.*s", 3 * n, s);
}
obviously it needs extending for numbers larger than 11.
The string may get rather large...
for instance to handle all 5 digit numbers and smaller I estimate
the string would be >500,000 characters. This would break printf()
if integers are only 16-bit.