int aaa() {printf(“Hi”);}

int bbb(){printf(“hello”);}

iny ccc(){printf(“bye”);}

main()

{

int ( * ptr[3]) ();

ptr[0] = aaa;

ptr[1] = bbb;

ptr[2] =ccc;

ptr[2]();

}



int aaa() {printf(“Hi”);} int bbb(){printf(“hello”);} iny ccc(){printf(“..

Answer / susie

Answer :

bye

Explanation:

int (* ptr[3])() says that ptr is an array of pointers to
functions that takes no arguments and returns the type int.
By the assignment ptr[0] = aaa; it means that the first
function pointer in the array is initialized with the
address of the function aaa. Similarly, the other two array
elements also get initialized with the addresses of the
functions bbb and ccc. Since ptr[2] contains the address of
the function ccc, the call to the function ptr[2]() is same
as calling ccc(). So it results in printing "bye".

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C Code Interview Questions

why the range of an unsigned integer is double almost than the signed integer.

1 Answers  


Write a program that find and print how many odd numbers in a binary tree

1 Answers  


main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }

2 Answers   Adobe, CSC,


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


main() { char not; not=!2; printf("%d",not); }

1 Answers  






what is the code of the output of print the 10 fibonacci number series

2 Answers  


how to print 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 using any loop(for or while) only once(only 1 loop) and maximum 2 variables using C.

19 Answers   Cap Gemini, Infosys,


Finding a number multiplication of 8 with out using arithmetic operator

8 Answers   Eyeball, NetApp,


write a program in c to merge two array

2 Answers  


There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong? void main() { struct student { char name[30], rollno[6]; }stud; FILE *fp = fopen(“somefile.dat”,”r”); while(!feof(fp)) { fread(&stud, sizeof(stud), 1 , fp); puts(stud.name); } }

1 Answers  


Write a program to check whether the number is prime and also check if it there i n fibonacci series, then return true otherwise return false

1 Answers   Cognizant, lenovo,


main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }

4 Answers   CSC,


Categories