What is the hidden bug with the following statement?
assert(val++ != 0);
Answer / susie
Answer : & Explanation:
Assert macro is used for debugging and removed in release
version. In assert, the experssion involves side-effects. So
the behavior of the code becomes different in case of debug
version and the release version thus leading to a subtle bug.
Rule to Remember:
Don’t use expressions that have side-effects in assert
statements.
Is This Answer Correct ? | 2 Yes | 0 No |
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
How to reverse a String without using C functions ?
33 Answers Matrix, TCS, Wipro,
char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }
void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }
print a semicolon using Cprogram without using a semicolon any where in the C code in ur program!!
35 Answers Tata Elxsi, TCS, VI eTrans,
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!
main() { int i = 3; for (;i++=0;) printf(“%d”,i); }
main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } } a. 0, 0 b. 0, 513 c. 512, 0 d. 0, -513
3 Answers HCL, Logical Computers,
Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);
Program to find the largest sum of contiguous integers in the array. O(n)
Who could write how to find a prime number in dynamic array?
Write a prog to accept a given string in any order and flash error if any of the character is different. For example : If abc is the input then abc, bca, cba, cab bac are acceptable, but aac or bcd are unacceptable.