C | Functions | Question 7

Predict the output?

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
int main()
{
    void demo();
    void (*fun)();
    fun = demo;
    (*fun)();
    fun();
    return 0;
}
  
void demo()
{
    printf("GeeksQuiz ");
}

chevron_right


(A) GeeksQuiz
(B) GeeksQuiz GeeksQuiz
(C) Compiler Error
(D) Blank Screen


Answer: (B)

Explanation: This is a simple program with function pointers. fun is assigned to point to demo. So the two statements “(*fun)();” and “fun();” mean the same thing.

Quiz of this Question

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.