Write a program that prompts the user to input a four-digit positive integer. The program then outputs
the digits of the number, one digit per line. For example, if the input is 3245, the output is:
3
2
4
5
#include <stdio.h>
int main()
{
int num, x, y, z, m = 0;
printf("Please enter a four digit number: ");
scanf("%d", &num);
printf("\n");
m = num % 10000 / 1000;
printf("%d",m);
printf("\n");
z = num % 1000 / 100;
printf("%d",z);
printf("\n");
y = num % 100 / 10;
printf("%d",y);
printf("\n");
x = num % 10;
printf("%d",x);
printf("\n");
return 0;
}
Comments
Leave a comment