I just want to convert an int number such as 5267 or 1000000 into seperated integeres.
like for number 5267 it be 5 2 6 7 , so i can print them with putchar(). I know, but i have to use only putchat and getchar in my code. ( no printf or scanf).
I had some thoughts about it but the only thing that i came up is this code which prints the number backward: PLS helpPLS:::::
[CODE=c]
int num=5267 /*for example*/
int d;
while(1<=num/10)
{
d=num%10+48; /*im addind 48 to get the num charah from ASCII*/
putchar(d);
num=num/10;
}
num=num+48;
putchar(num);
}[/CODE]
this will print the num 5267 as 7625.
like for number 5267 it be 5 2 6 7 , so i can print them with putchar(). I know, but i have to use only putchat and getchar in my code. ( no printf or scanf).
I had some thoughts about it but the only thing that i came up is this code which prints the number backward: PLS helpPLS:::::
[CODE=c]
int num=5267 /*for example*/
int d;
while(1<=num/10)
{
d=num%10+48; /*im addind 48 to get the num charah from ASCII*/
putchar(d);
num=num/10;
}
num=num+48;
putchar(num);
}[/CODE]
this will print the num 5267 as 7625.
Comment