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