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 |
main() { int i=5,j=6,z; printf("%d",i+++j); }
void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }
Cau u say the output....?
What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }
main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }
Is this code legal? int *ptr; ptr = (int *) 0x400;
You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.
write a program to count the number the same (letter/character foreg: 's') in a given sentence.
Write a C program that defines a 2-dimentional integer array called A [50][50]. Then the elements of this array should randomly be initialized either to 1 or 0. The program should then print out all the elements in the diagonal (i.e. a[0][0], a[1][1],a[2][2], a[3][3], ……..a[49][49]). Finally, print out how many zeros and ones in the diagonal.
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)
main ( ) { static char *s[ ] = {“black”, “white”, “yellow”, “violet”}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf(“%s”,*--*++p + 3); }
void main() { int i=i++,j=j++,k=k++; printf(“%d%d%d”,i,j,k); }