Question
Write a program that prompts a user for an integer value inthe range 0 to 32,767 and then prints the individual digits of thenumber on a line with three spaces between the digits. The firstline is to start with the leftmost digit and print all five digits;the second line is to start with the secong digit from the left andprint four digits, and so forth. For example, if the user enters1234, your program should print 0 1 2 3 4 1 2 3 4 2 3 4 3 4 4 Write a program that prompts a user for an integer value inthe range 0 to 32,767 and then prints the individual digits of thenumber on a line with three spaces between the digits. The firstline is to start with the leftmost digit and print all five digits;the second line is to start with the secong digit from the left andprint four digits, and so forth. For example, if the user enters1234, your program should print 0 1 2 3 4 1 2 3 4 2 3 4 3 4 4
Explanation / Answer
please rate - thanks #include #include int main() {int n=10000,i,j,temp,left,digit,tempn,num; printf("Enter a number: "); scanf("%d",&num); for(i=0;i=1;j--) {digit=temp/tempn; temp=temp-digit*tempn; printf("%d ",digit); tempn/=10; } num%=n; n/=10; printf(" "); } getch(); return 0; }