8th Sep 2019, 7:30 AM
Noor ❤
Noor ❤ - avatar
11 odpowiedzi
+ 4
Yes. But in your version, it calls foo() ONE time. Defining it in main DOESN'T mean it is automatically called.
8th Sep 2019, 7:41 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
+ 5
Sagnik Ray void foo() isn't call !!! It's just prototype
11th Sep 2019, 9:55 AM
UraL
+ 4
f() is called in main again, so it must have called foo ()??
8th Sep 2019, 7:36 AM
Noor ❤
Noor ❤ - avatar
+ 4
Call f() is only 1 time
11th Sep 2019, 9:40 AM
UraL
+ 3
Not understand the problem. All is clear and easy
11th Sep 2019, 9:40 AM
UraL
+ 2
#include <stdio.h> int main() { void foo(); void f() { foo(); } f(); } void foo () { printf ("2 "); } In the main function when you called "foo()" you used the "void" keyword. So it is calling itself but not returns any value. #include <stdio.h> int main() { foo(); void f() { foo(); } f(); } void foo () { printf ("2 "); } If you perform the above code it will print "2 2" instead of "2".
10th Sep 2019, 4:32 AM
Sagnik Ray
Sagnik Ray - avatar
+ 2
Yeah Ural you are right its a prototype. But she didn't need to mention the prototype. Instead if she calls foo() and f() both then the output is 2 2 and not 2 and she does not need to call f() two times. And Now I understood the problem. Thank you.
14th Sep 2019, 10:32 AM
Sagnik Ray
Sagnik Ray - avatar
+ 2
A little modification to the code to get output "2 2" The Code: #include <stdio.h> int main() { int f() { if(foo()==NULL){ } return 2; } int n = f(); printf(" %d",n); } void foo () { printf ("2" ); } In the above code you can call f() only once to get output "2 2" Its just an alternative method.
14th Sep 2019, 11:30 AM
Sagnik Ray
Sagnik Ray - avatar
+ 1
f() calls foo(), stop. Or you call two times f(), or in f() you call two times foo() https://code.sololearn.com/cqRr522H3H2E/?ref=app
8th Sep 2019, 7:33 AM
Paolo De Nictolis
Paolo De Nictolis - avatar
0
#😎😎😎 #include <stdio.h> int main() { void f() { foo(); } f(); } void foo () { printf ("2 "); main(); } Try this 😎😎😎
15th Sep 2019, 11:55 AM
Anonymous
Anonymous - avatar