main()

{

char *a = "Hello ";

char *b = "World";

clrscr();

printf("%s", strcpy(a,b));

}

a. “Hello”

b. “Hello World”

c. “HelloWorld”

d. None of the above

Answers were Sorted based on User's Feedback



main() { char *a = "Hello "; char *b = "World"; cl..

Answer / guest

d) World, copies World on a, overwrites Hello in a.

Is This Answer Correct ?    13 Yes 1 No

main() { char *a = "Hello "; char *b = "World"; cl..

Answer / sandeep tayal

This would produce an error message if you are using g++
compiler in UNIX as g++ does not allow constant strings to
be a part of the char *;

If this is run in Turbo C then it will produce the output
shown in above

Is This Answer Correct ?    3 Yes 0 No

main() { char *a = "Hello "; char *b = "World"; cl..

Answer / sanjay bhosale

This produces runtime exception as we are attempting to read or write protected memory in Visual c++.

Is This Answer Correct ?    1 Yes 0 No

main() { char *a = "Hello "; char *b = "World"; cl..

Answer / vijeselvam

answer is (d)

The correct answer will be "HelloHello"

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Code Interview Questions

Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique.

5 Answers   IITR, Microsoft, Nike,


void main() { static int i=i++, j=j++, k=k++; printf(“i = %d j = %d k = %d”, i, j, k); }

3 Answers  


main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  


source code for delete data in array for c

1 Answers   TCS,


# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }

1 Answers  






Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines

0 Answers   IBM,


#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, j; scanf("%d %d"+scanf("%d %d", &i, &j)); printf("%d %d", i, j); } a. Runtime error. b. 0, 0 c. Compile error d. the first two values entered by the user

2 Answers   HCL,


main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }

4 Answers   CSC,


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

2 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 code of the output of print the 10 fibonacci number series

2 Answers  


Categories