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 do I write a program to print proper subset of given string . Eg :input: abc output:{},{a},{b},{c},{a,b},{a,c},{b,c}, {a,b,c}.I desperately need this program please mail me to saravana6m@gmail.com

11 Answers   Deshaw, Infosys,


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

3 Answers  


# include<stdio.h> aaa() { printf("hi"); } bbb(){ printf("hello"); } ccc(){ printf("bye"); } main() { int (*ptr[3])(); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2](); }

1 Answers  


main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”

5 Answers   HCL,


union u { struct st { int i : 4; int j : 4; int k : 4; int l; }st; int i; }u; main() { u.i = 100; printf("%d, %d, %d",u.i, u.st.i, u.st.l); } a. 4, 4, 0 b. 0, 0, 0 c. 100, 4, 0 d. 40, 4, 0

1 Answers   HCL,






main() { register int a=2; printf("Address of a = %d",&a); printf("Value of a = %d",a); }

3 Answers  


main() { int i=10; void pascal f(int,int,int); f(i++,i++,i++); printf(" %d",i); } void pascal f(integer :i,integer:j,integer :k) { write(i,j,k); }

1 Answers  


#define DIM( array, type) sizeof(array)/sizeof(type) main() { int arr[10]; printf(“The dimension of the array is %d”, DIM(arr, int)); }

1 Answers  


Write a procedure to implement highlight as a blinking operation

2 Answers  


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

1 Answers  


&#8206;#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


How we print the table of 3 using for loop in c programing?

7 Answers  


Categories