C Programming - Functions - Discussion
Discussion Forum : Functions - Point Out Correct Statements (Q.No. 1)
1.
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
printf("%p\n", main());
return 0;
}
Answer: Option
Explanation:
In printf("%p\n", main()); it calls the main() function and then it repeats infinetly, untill stack overflow.
Discussion:
15 comments Page 1 of 2.
Rupinderjit said:
1 decade ago
%p is used to print the address of some variable as used by the host computer.It can be Hex Binary BCD unsigned or any.
(1)
Ankur said:
1 decade ago
it generate error becouse main function can not call inside the main() function.
Lav said:
1 decade ago
What is %p ?
Varun said:
1 decade ago
Thank you. @Rupinderjit.
Dhiraj said:
1 decade ago
Why it does not print 0 infinite times ? When stack overflows main return 0 and that value get printed.
Krishanu said:
1 decade ago
Again I want to say that the actual output will be:
"Segmentation fault (core dumped)".
"Segmentation fault (core dumped)".
Lakshmi said:
1 decade ago
What is the meaning of "Segmentation fault"?
Cheeku said:
9 years ago
It will print the address of main.
Prashanth said:
9 years ago
Output : Segmentation fault (core dumped).
Asish panigrahi said:
9 years ago
%p has no value so that it prints infinite garbage value.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers