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

Derive expression for converting RGB color parameters to HSV values

1 Answers  


void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


Cluster head selection in Wireless Sensor Network using C programming language.

0 Answers  


What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }

1 Answers  






main() { int i=10; i=!i>14; Printf ("i=%d",i); }

1 Answers  


#include<stdio.h> #include<conio.h> void main() { int a=(1,2,3,(1,2,3,4); switch(a) { printf("ans:"); case 1: printf("1");break; case 2: printf("2");break; case 3: printf("1");break; case 4: printf("4");break; printf("end"); } getch(); }

0 Answers  


main() { char c; int i = 456; clrscr(); c = i; printf("%d", c); } a. 456 b. -456 c. random number d. none of the above

3 Answers   BrickRed, HCL,


main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error

1 Answers   HCL,


#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

1 Answers  


main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }

1 Answers  


¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...

3 Answers  


Categories