# C practical exercise topic 29

Time：2020-9-23

Title:To give a positive integer with no more than 5 digits, the requirements are as follows: 1. Find the number of digits; 2. Print out the numbers in reverse order.

Program analysis:Learn to break down each digit, as explained below.

example:

``````#include

int main( )
{
long a,b,c,d,e,x;
scanf("%ld",&x);
A = x / 10000; / * decomposes ten thousand bits*/
B = x% 10000 / 1000; / * decomposed into thousands*/
C = x% 1000 / 100; / * decomposes into hundreds*/
D = x% 100 / 10; / * decomposes into ten bits*/
E = x% 10; / * decomposes into bits*/
if (a!=0){
Printf ("is 5 digits, reverse order is: LD% LD% LD% LD% LD% LD, e, D, C, B, a)";
} else if(b!=0) {
Printf ("is 4 digits, reverse order is: LD% LD% LD% LD / N", e, D, C, b);
} else if(c!=0) {
Printf ("is 3 digits, reverse order is: LD% LD% LD / N", e, D, c);
} else if(d!=0) {
Printf ("is 2 digits, reverse order is% LD% LD / N", e, d);
} else if(e!=0) {
Printf ("is 1 digit, reverse order is% LD / N", e);
}
}``````

The output results of the above examples are as follows:

``````Please input 5 digits: 12345
The reverse order is 543 21``````