#include <stdio.h> void print_integer_as_string(int num) { // Your logic here char str[12]; if(num == 0) printf("0"); int i = 0,j=0,is_neg; if(num < 0) { is_neg = 1; num = -num; } while(num) { str[i++] = (num % 10) + '0'; num/=10; } if(is_neg){ str[i++] = '-'; } for(j = i-1;j >= 0;j--){ printf("%c ",str[j]); } } 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