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=5,j=6,z; printf("%d",i+++j); }

2 Answers  


main() { int i=5; printf("%d",++i++); }

1 Answers  


how many processes will gate created execution of -------- fork(); fork(); fork(); -------- Please Explain... Thanks in advance..!

8 Answers   GATE,


#include<stdio.h> main() { const int i=4; float j; j = ++i; printf("%d %f", i,++j); }

1 Answers  


Is it possible to print a name without using commas, double quotes,semi-colons?

7 Answers  






main() { int i; i = abc(); printf("%d",i); } abc() { _AX = 1000; }

2 Answers  


Finding a number which was log of base 2

1 Answers   NetApp,


Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.

0 Answers  


what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }

3 Answers   Wipro,


to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD output should of SAD

6 Answers   Synergy,


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

2 Answers   Wipro,


main() { int c = 5; printf("%d", main||c); } a. 1 b. 5 c. 0 d. none of the above

2 Answers   HCL,


Categories