main()

{

char *p = "hello world";

p[0] = 'H';

printf("%s", p);

}

a. Runtime error.

b. “Hello world”

c. Compile error

d. “hello world”

Answers were Sorted based on User's Feedback



main() { char *p = "hello world"; p[0] = 'H'; ..

Answer / ajay karanam

a. Runtime error.

Is This Answer Correct ?    22 Yes 9 No

main() { char *p = "hello world"; p[0] = 'H'; ..

Answer / deepesh sharma

The Answer is
a) Runtime Error.

Details: hello world is a constant string and the address of
the memory location where this string is stored is assigned
to p. In second line you are changing the value at that
address which is constant string hence changing a constant
is runtime error.

Is This Answer Correct ?    18 Yes 7 No

main() { char *p = "hello world"; p[0] = 'H'; ..

Answer / guest

b) Hello world

Is This Answer Correct ?    21 Yes 16 No

main() { char *p = "hello world"; p[0] = 'H'; ..

Answer / sandeep

answer:

Hello word

Is This Answer Correct ?    4 Yes 6 No

main() { char *p = "hello world"; p[0] = 'H'; ..

Answer / vijayanand yadav ("appu s

compile time error,
because of the semi colon present in the variable char *p="hello world";p[0]='H';here in this example the semi colon is just replaced with a , operator....

Is This Answer Correct ?    0 Yes 8 No

Post New Answer

More C Code Interview Questions

How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.

0 Answers  


How can i find first 5 natural Numbers without using any loop in c language????????

2 Answers   Microsoft,


void ( * abc( int, void ( *def) () ) ) ();

1 Answers  


Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list)

3 Answers   Disney, Google, ZS Associates,


main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n”", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above

3 Answers   HCL,






Finding a number multiplication of 8 with out using arithmetic operator

8 Answers   Eyeball, NetApp,


Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all.

2 Answers   Mentor Graphics, Microsoft,


Write a program to implement the motion of a bouncing ball using a downward gravitational force and a ground-plane friction force. Initially the ball is to be projected in to space with a given velocity vector

2 Answers  


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

1 Answers  


Is the following code legal? struct a { int x; struct a b; }

1 Answers  


x=2 y=3 z=2 x++ + y++; printf("%d%d" x,y);

2 Answers  


How to use power function under linux environment.eg : for(i=1;i<=n;i++){ pow(-1,i-1)} since it alerts undefined reference to 'pow'.

2 Answers  


Categories