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



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.