main( )

{

char *q;

int j;

for (j=0; j<3; j++) scanf(“%s” ,(q+j));

for (j=0; j<3; j++) printf(“%c” ,*(q+j));

for (j=0; j<3; j++) printf(“%s” ,(q+j));

}



main( ) { char *q; int j; for (j=0; j<3; j++) scanf(“%..

Answer / susie

Answer :

Explanation:

Here we have only one pointer to type char and since we take
input in the same pointer thus we keep writing over in the
same location, each time shifting the pointer value by 1.
Suppose the inputs are MOUSE, TRACK and VIRTUAL. Then for
the first input suppose the pointer starts at location 100
then the input one is stored as

M
O
U
S
E
\0
When the second input is given the pointer is incremented as
j value becomes 1, so the input is filled in memory starting
from 101.

M
T
R
A
C
K
\0
The third input starts filling from the location 102

M
T
V
I
R
T
U
A
L
\0
This is the final value stored .

The first printf prints the values at the position q,
q+1 and q+2 = M T V

The second printf prints three strings starting from
locations q, q+1, q+2

i.e MTVIRTUAL, TVIRTUAL and VIRTUAL.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Code Interview Questions

main() { int i=-1,j=-1,k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d %d %d %d %d",i,j,k,l,m); }

1 Answers  


Write a program that reads a dynamic array of 40 integers and displays only even integers

2 Answers  


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

2 Answers  


respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

1 Answers   Genpact, Ozdocs,


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,






How to palindrom string in c language?

6 Answers   Google,


main() { extern int i; i=20; printf("%d",i); }

1 Answers   Value Labs,


main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


main() { float i=1.5; switch(i) { case 1: printf("1"); case 2: printf("2"); default : printf("0"); } }

2 Answers  


main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }

2 Answers   Wipro,


how to swap 3 nos without using temporary variable

4 Answers   Satyam,


main() { int i, j, *p; i = 25; j = 100; p = &i; // Address of i is assigned to pointer p printf("%f", i/(*p) ); // i is divided by pointer p } a. Runtime error. b. 1.00000 c. Compile error d. 0.00000

3 Answers   HCL,


Categories