#include <stdio.h> void print_integer_as_string(int num) { // Your logic here if(0 == num){ putchar('0'); return; } if(num < 0){ putchar('-'); putchar(' '); num = -num; } char digits[10]; int digit_idx = 0; while(num) { digits[digit_idx++] = '0'+(num%10); num = num/10; } while(digit_idx) { putchar(digits[--digit_idx]); if(0!=digit_idx) putchar(' '); } } int main() { int num; scanf("%d", &num); print_integer_as_string(num); return 0; }
Test Cases
Test Results
Input
123
Expected Output
1 2 3