#define assert(cond) if(!(cond)) \
(fprintf(stderr, "assertion failed: %s, file %s,
line %d \n",#cond,\
__FILE__,__LINE__), abort())
void main()
{
int i = 10;
if(i==0)
assert(i < 100);
else
printf("This statement becomes else for if in
assert macro");
}
Answer / susie
Answer :
No output
Explanation:
The else part in which the printf is there becomes the else
for if in the assert macro. Hence nothing is printed.
The solution is to use conditional operator instead of
if statement,
#define assert(cond) ((cond)?(0): (fprintf (stderr,
"assertion failed: \ %s, file %s, line %d \n",#cond,
__FILE__,__LINE__), abort()))
Note:
However this problem of “matching with nearest else” cannot
be solved by the usual method of placing the if statement
inside a block like this,
#define assert(cond) { \
if(!(cond)) \
(fprintf(stderr, "assertion failed: %s, file %s,
line %d \n",#cond,\
__FILE__,__LINE__), abort()) \
}
Is This Answer Correct ? | 5 Yes | 0 No |
main() { int i=300; char *ptr = &i; *++ptr=2; printf("%d",i); }
main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(“%u %u %u %d \n”,a,*a,**a,***a); printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1); }
main() { char *p="hai friends",*p1; p1=p; while(*p!='\0') ++*p++; printf("%s %s",p,p1); }
Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique.
5 Answers IITR, Microsoft, Nike,
Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.
21 Answers ABC, eBay, Goldman Sachs, Google, HUP, Microsoft, TATA,
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,
void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }
What is your nationality?
Predict the Output: int main() { int *p=(int *)2000; scanf("%d",2000); printf("%d",*p); return 0; } if input is 20 ,what will be print
main() { int i=-1; +i; printf("i = %d, +i = %d \n",i,+i); }
#define a 10 void foo() { #undef a #define a 50 } int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } explain the answer
¦void main() ¦{ ¦int i=10,j; ¦ j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-30 but in same question if we write as- ¦void main() ¦{ ¦int i=10; ¦ int j=i+++i+++i; ¦printf("%d",j); ¦getch(); ¦} ¦ output:-33 why output is changed from 30 to 33. Can any body answer...