Print an integer using putchar only
#include <stdio.h>
int main (int argc, char** argv) {
int i=390487;
int base=10;
int remainder=0;
for (remainder=i/base;
remainder>0;
base*=10,remainder=i/base);
base=base/10;
remainder=i;
while (base>0) {
putchar('0'+remainder/base);
remainder=remainder-(remainder/base)*base;
base/=10;
}
putchar('\n');
return 0;
}
0 Comments:
Post a Comment
<< Home