3i Infotech Placement: Sample Questions 388 - 390 of 1245
Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.
Question 388
Write in Short Short Answer▾
#define int char
main ()
{
int i =65;
printf ( “sizeof (i) =%d” sizeof (i) );
}
Explanation
In a program
#define int char | #define replaces the string int by the macro char |
main () { int i = 65; printf ( “sizeof (i) =% d” sizeof (i) ) ; } | Here , int value replace in char value Then, print sizeof (i) = 1 Because, character variable minimum size is 1 byte or 1 character |
Question 389
Explanation
Yes, both argc and argv are local to main method.
Question 390
Describe in Detail Essay▾
What is the output of the following program?
#define assert (cond) if ( (cond)! ) ⧵ (fprintf (stderr, “assertion failed:%s, file %s, line %d ” #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” );
}
Explanation
- In the program
#define assert (cond) if ( (cond) !) ⧵ (fprintf (stderr, “assertion failed:% s, file % s, line % d” #cond, ⧵ ________FILE________, ________LINE________) , abort () ) |
|
if (i == 0) assert (i < 100) ; |
|
- Note: 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” , #cond, ⧵ ________FILE________, ________LINE________) , abort () ) ⧵}