Preprocessor & Macros

1. What is the output of this program?

#include <stdio.h>
#define int char
main()
{
int i=50;
printf ("sizeof (i) =%d", sizeof (i));
}

A. 2
B. 4
C. 8
D. 1

View Answer


2. What is the output of this program?

#include <stdio.h>
#define x 3
int main()
{
int i;
i = x*x*x;
printf("%d",i);
return 0;
}

A. 27
B. x is not declared
C. No output
D. Garbage value

View Answer


3. What is the output of this program?

#include <stdio.h>
#include <stdlib.h>
#define square(x) x*x
int main()
{
int i;
i = 27/square(3);
printf("%d",i);
return 0;
}

A. 9
B. Compilation error
C.3
D. 27

View Answer


4. What is the output of this program?

#include <stdio.h>
#define i 5
int main()
{
#define i 10
printf("%d",i);
return 0;
}

A. Compilation error
B. 10
C. 5
D. Runtime error

View Answer


5. What is the output of this program?

#include<stdio.h>
#define clrscr() 17
int main()
{
clrscr();
printf("%d\n",clrscr());
return 0;
}

A. Compilation error
B. Runtime error
C. 17
D. none of the above

View Answer


6. #include<stdio.h>
30;
int main()
{
printf("%d\n",30);
return 0;
}

A. Runtime Error
B. Garbage value
C. Compilation error
D. 30

View Answer


7. What is the output of this program?

#include <stdio.h>
#define p 17;
int main()
{
printf("%d",p);
return 0;
}

A. Garbage value
B. Runtime error
C.17
D. Compilation error

View Answer


8. Which statment is true about the given code ?

#include <stdio.h>
enum colors {lets,find,course};
int main()
{
printf("%d %d %d",course,lets,find);
return 0;
}

A. 3 1 2
B. 2 0 1
C. 0 1 2
D. 1 0 2

View Answer


9. What is the Error of this program?

#include <stdio.h>
#define CONDITION(x)
printf("letsfindcourse\n");
int main()
{
CONDITION(0);
return 0;
}

A. letsfindcourse
B. Runtime error
C. Compilation error
D. none of the above

View Answer


10. How will you free the memory allocated by the following program? #include<stdio.h>
#define CONDITION(x)\
printf("letsfindcourse\n");
int main()
{
CONDITION(0);
return 0;
}

A. Runtime Error
B. Compilation error
C. letsfindcourse
D. None of the one

View Answer







Also check :


Discussion


* You must be logged in to add comment.