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

how to concatenate the two strings

1 Answers  


how to return a multiple value from a function?

5 Answers   Wipro,


main() { printf("%x",-1<<4); }

3 Answers   HCL, Sokrati, Zoho,


#define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }

4 Answers   Google, HCL, Quick Heal, WTF,


main() { int i; clrscr(); printf("%d", &i)+1; scanf("%d", i)-1; } a. Runtime error. b. Runtime error. Access violation. c. Compile error. Illegal syntax d. None of the above

1 Answers   HCL,






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

1 Answers  


What is "far" and "near" pointers in "c"...?

3 Answers  


void main() { int c; c=printf("Hello world"); printf("\n%d",c); }

2 Answers  


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

0 Answers   Mbarara University of Science and Technology,


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  


#include<stdio.h> main() { FILE *ptr; char i; ptr=fopen("zzz.c","r"); while((i=fgetch(ptr))!=EOF) printf("%c",i); }

1 Answers  


Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

16 Answers   Aricent, Cisco, Directi, Qualcomm,


Categories