In C i can't simply use putchar(5);
I have to do it like this
#include <stdio.h>
int main(){
int c=5;
putchar(c+'0');
putchar('\n');
return 0;
}
the output is 5.
But I can't do this for double digit numbers like 10 or 25. My question is , is it possible to print out 10 using putchar and putchar only?
I can't do it like this
int c=10;
putchar(c+'0');
The output would be':' because ':' has the ASCII value of 58.
If it is only numbers you can try the below logic.