1 /*C How to Program, 6/E, Deitel & Deitel.
3 Solution of exercise 2.30:
4 (Separating Digits in an Integer) Write a program that inputs one five-digit
5 number, separates the number into its individual digits and prints the digits
6 separated from one another by three spaces each. [Hint: Use combinations of
7 integer division and the remainder operation.] For example, if the user types
8 in 42139, the program should print
12 Written by Juan Carlos Moreno (jcmhsoftware@gmail.com), year 2018.*/
20 /*The five digits of the number*/
33 printf("Enter the number of five digits: ");
36 first_digit
= number
/ 10000;
37 first_remainder
= number
% 10000;
39 second_digit
= first_remainder
/ 1000;
40 second_remainder
= first_remainder
% 1000;
42 third_digit
= second_remainder
/ 100;
43 third_remainder
= second_remainder
% 100;
45 fourth_digit
= third_remainder
/ 10;
46 fourth_remainder
= third_remainder
% 10;
48 /*The fourth remainder is the fifth digit*/
49 fifth_digit
= fourth_remainder
;
51 /*Print the digits separated by three spaces*/
52 printf("%d ", first_digit
);
53 printf("%d ", second_digit
);
54 printf("%d ", third_digit
);
55 printf("%d ", fourth_digit
);
56 printf("%d\n", fifth_digit
);