Write a recursive function in C language that can output the digits of a multi-digit integer in positive order. (with detailed code)

Using a recursive function, output the digits of a value in positive order

For example, enter 123546 to get the positive sequence number of 1 2 3 4 5 6

code show as below:

#include<stdio.h>

void printDigit(int data)
{
	if(data==0) return;
	 printDigit(data/10);
	 printf("%d ",data%10);
}

int main()
{
	int n;
	scanf("%d",&n);
	printDigit(n);
	return 0;
}

The result of the operation is as follows:

123456
1 2 3 4 5 6
--------------------------------
Process exited after 7.046 seconds with return value 0
Please press any key to continue. . .

 

Guess you like

Origin blog.csdn.net/m0_58941767/article/details/119538748