Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


#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");

}



#define assert(cond) if(!(cond)) \ (fprintf(stderr, "assertion failed: %s, file %s, ..

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

Post New Answer

More C Code Interview Questions

what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }

3 Answers   Wipro,


main() { main(); }

1 Answers  


What are segment and offset addresses?

2 Answers   Infosys,


void main() { int i=5; printf("%d",i+++++i); }

3 Answers  


How we print the table of 3 using for loop in c programing?

7 Answers  


respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

1 Answers   Genpact, Ozdocs,


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

0 Answers   TCS,


void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }

3 Answers   Accenture,


There is a lucky draw held every day. if there is a winning number eg 1876,then all possible numbers like 1867,1687,1768 etc are the numbers that match irrespective of the position of the digit. Thus all these numbers qualify fr the lucky draw prize Assume there is no zero digit in any numbers. write a program to show all the possible winning numbers if a "winning number"is passed as an arguments to the function.

1 Answers   Nagarro,


Derive expression for converting RGB color parameters to HSV values

1 Answers  


main() { char s[ ]="man"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }

1 Answers   DCE,


main() { int *j; { int i=10; j=&i; } printf("%d",*j); }

9 Answers   HCL, Wipro,


Categories