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

write a program to find out roots of quadratic equation "x=-b+-(b^2-4ac0^-1/2/2a"

2 Answers  


Is the following code legal? void main() { typedef struct a aType; aType someVariable; struct a { int x; aType *b; }; }

1 Answers  


Write a C function to search a number in the given list of numbers. donot use printf and scanf

5 Answers   Honeywell, TCS,


main() { printf("%d", out); } int out=100;

3 Answers  


#include<stdio.h> main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }

1 Answers  






why is printf("%d %d %d",i++,--i,i--);

4 Answers   Apple, Cynity, TCS,


write a c-program to display the time using FOR loop

3 Answers   HCL,


Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

13 Answers   Intel, Microsoft, TCS,


find simple interest & compund interest

2 Answers  


main() { char *p="GOOD"; char a[ ]="GOOD"; printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d", sizeof(p), sizeof(*p), strlen(p)); printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a), strlen(a)); }

1 Answers  


can u give me the c codings for converting a string into the hexa decimal form......

1 Answers  


main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }

1 Answers  


Categories