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

abcdedcba abc cba ab ba a a

2 Answers  


int DIM(int array[]) { return sizeof(array)/sizeof(int ); } main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr)); }

2 Answers   CSC,


How to count a sum, when the numbers are read from stdin and stored into a structure?

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,


what will be the position of the file marker? a: fseek(ptr,0,SEEK_SET); b: fseek(ptr,0,SEEK_CUR);

2 Answers  






why java is platform independent?

13 Answers   Wipro,


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

0 Answers   TCS,


To reverse an entire text file into another text file.... get d file names in cmd line

0 Answers   Subex,


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

1 Answers  


struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above

2 Answers   HCL,


What is the output for the program given below typedef enum errorType{warning, error, exception,}error; main() { error g1; g1=1; printf("%d",g1); }

1 Answers  


main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }

3 Answers   GNITC,


Categories