+ 2
Why the output 332?
22 Respostas
+ 3
~ swim ~
Thank you..
+ 3
~ swim ~
If I'm wrong anywhere please correct me, pointers are tough to understand by me
+ 3
~swim~
Thanks again..
+ 2
int main(){
f("123");
}
void f(char a[]) //a[]="123" (1)
{
if(a[1]=='\0') //a[]=2
return;
}f(a+1); //a[]="23". (2)
f(a+1); //a[]="3". (3)(4)
printf("%c", a[1]);
}
(4) for this does nothing but returns to same function. after competing inner loops.
(3)for this, after completing inner loops control backs here, and Now a[]=23 so a[1]=3;
(2)same way, for this now a[1]=3
(1)and for this now a[1]=2
So output is 332
+ 2
First f("123")
This call is completed after 3 more times f() call completed.
See f("123") has to call
f("a+1") and f("a+1"). In this first f("a+1") call again f("a+1") call after it completion of execution. So totally 4 times f executed.
Read comments...
+ 1
Jayakrishna I need both.
0
Jayakrishna how does the last recursion a[]="3" print 3?
0
Jayakrishna ty
0
After completion of a function execution control comes after the next statement so there is another time f() needed to execute.
First main calls
F(123)=>f(23), => f(23)=>f(3)<=
^ =>f(3)<=return
when ever function call another function, the values are pushed in to the stack.
So fisrt f("123") ,a=123
when it calling f(a+1), ,f("123"), and a=123 ,are pushed unto stack.
f(a+1) ,a=23, pushed to stack.
again recursivly calls f(a+1), this goes on until a[1]=='\0'.
2nd f(a+1) does same with a=23
Now, stack contains retyrning,
23
23
123
poped of ,completing last function completing first until first call f("123")
So 23 =>a[1] =3
23= >a[1]=3
123=>a[1]=2
0
Hima see this. May be You can understand clearly what happening.. Hoping this give you clear explanation. Reply after for any....
https://code.sololearn.com/c9SbCgm6Giym/?ref=app
0
Jayakrishna could you also see this code?
https://code.sololearn.com/c29X66e1z1uU/?ref=app
0
Hima
Did you understand completely the previous one? If you don't understand in some where, reply that. I may missed some point there. I will reframe and reply. Some of those are confused ones.. So reply if you don't understand.
0
Jayakrishna I got it. ty:
0
Run the last one i updated.
What about second one? What you need from that? Output? Or explanation?
0
~ swim ~
(struct name*)0; converts int 0 to explicit (struct name*)
what it means ? What it pointing to then?
And (*(*int)) ?
Ponter to pointer convertion? Is it possible?
0
Well, I got no idea.