current position:Home>Why is x output 13 instead of 3

Why is x output 13 instead of 3

2022-02-02 14:25:19 CSDN Q & A

include <stdio.h>

void fun(int x)

{

if(x/2>0)

{

fun(x/2);

}

printf("%d",x);

}

main()

{

fun(3);

printf("\n");

}




Refer to the answer 1:

x / 2 == 1 > 0 therefore
fun(1): 1 / 2 == 0, So print 1, Exit function
Print 3, Final printing effect 13




Refer to the answer 2:



Refer to the answer 3:

You think so , It was called twice fun()
Every time fun() Finally, a value will be output




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202021425172364.html

Random recommended