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);

}



main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int..

Answer / susie

Answer :

g20fy

Explanation:

Since a void pointer is used it can be type casted to any
other type pointer. vp = &ch stores address of char ch and
the next statement prints the value stored in vp after type
casting it to the proper data type pointer. the output is
‘g’. Similarly the output from second printf is ‘20’. The
third printf statement type casts it to print the string
from the 4th value hence the output is ‘fy’.

Is This Answer Correct ?    4 Yes 0 No

Post New Answer

More C Code Interview Questions

#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  


struct aaa{ struct aaa *prev; int i; struct aaa *next; }; main() { struct aaa abc,def,ghi,jkl; int x=100; abc.i=0;abc.prev=&jkl; abc.next=&def; def.i=1;def.prev=&abc;def.next=&ghi; ghi.i=2;ghi.prev=&def; ghi.next=&jkl; jkl.i=3;jkl.prev=&ghi;jkl.next=&abc; x=abc.next->next->prev->next->i; printf("%d",x); }

1 Answers  


what is variable length argument list?

2 Answers  


main() { int i=5; printf(“%d”,i=++i ==6); }

1 Answers  


main() { unsigned int i=65000; while(i++!=0); printf("%d",i); }

1 Answers  






void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }

1 Answers  


write a program in c language to get the value of arroy keys pressed and display the message which arrow key is pressed?

1 Answers  


1. const char *a; 2. char* const a; 3. char const *a; -Differentiate the above declarations.

3 Answers  


How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!

1 Answers  


How will u find whether a linked list has a loop or not?

8 Answers   Microsoft,


How to access command-line arguments?

4 Answers  


main() { int i; float *pf; pf = (float *)&i; *pf = 100.00; printf("\n %d", i); } a. Runtime error. b. 100 c. Some Integer not 100 d. None of the above

2 Answers   HCL, LG,


Categories