Discussion
Can we use a function as a parameter of another function? [ Eg: void wow(int func()) ]
Answer: C
Correct answer: Yes, but we call the function again to get the value, not as convenient as in using variable
C does allow it: a parameter written as a function is adjusted to a pointer to that function, so void wow(int func()) means void wow(int (*func)()). But what is passed is the function itself, not a value - so inside wow you must call it to obtain anything, which is less convenient than passing the value. This is the mechanism behind callbacks, such as the comparison function given to qsort.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development