#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 |
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql
main() { int *j; { int i=10; j=&i; } printf("%d",*j); }
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!
main() { char *a = "Hello "; char *b = "World"; clrscr(); printf("%s", strcat(a,b)); } a. Hello b. Hello World c. HelloWorld d. None of the above
Write a function to find the depth of a binary tree.
13 Answers Adobe, Amazon, EFI, Imagination Technologies,
how to check whether a linked list is circular.
void main() { int k=ret(sizeof(float)); printf("\n here value is %d",++k); } int ret(int ret) { ret += 2.5; return(ret); }
How will you print % character? a. printf(“\%”) b. printf(“\\%”) c. printf(“%%”) d. printf(“\%%”)
main() { struct date; struct student { char name[30]; struct date dob; }stud; struct date { int day,month,year; }; scanf("%s%d%d%d", stud.rollno, &student.dob.day, &student.dob.month, &student.dob.year); }
why nlogn is the lower limit of any sort algorithm?
Program to Delete an element from a doubly linked list.
4 Answers College School Exams Tests, Infosys,
main() { int i=400,j=300; printf("%d..%d"); }