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
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 |
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 |
Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)
#define int char main() { int i=65; printf("sizeof(i)=%d",sizeof(i)); }
main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }
How do you write a program which produces its own source code as its output?
main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }
#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }
main() { int *ptr=(int*)malloc(sizeof(int)); *ptr=4; printf("%d",(*ptr)+++*ptr++); }
Write a program using one dimensional array to assign values and then display it on the screen. Use the formula a[i]=i*10 to assign value to an element.
1 Answers Samar State University,
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,
why java is platform independent?
write a c program to Reverse a given string using string function and also without string function
Cau u say the output....?