Top

C Preprocessor

101.

Identify the macro(s) defined in stdarg.h.

Answer: D

The macro(s) defined in stdarg.h is all.

Enter details here

102.

What will be the output of the following C code?

#include
#define sf 10
main()
{
    if(sf==100)
        printf("good");
    else
    {
        printf("bad");
        sf=100;
    }
    printf("%d",sf);
}

 

Answer: D

The above code will result in an error because a macro cannot be defined using a simple assignment operator. In the code shown above, the value of sf is changed to 100 using the assignment operator. This causes an error.

Enter details here

Answer: C

No answer description available for this question.

Enter details here

104.

There exists a way to prevent the same file from getting #included twice in the same program.

Answer: A

No answer description available for this question.

Enter details here

105.

Macros have a local scope.

Answer: B

False, The scope of macros is globals and functions. Also the scope of macros is only from the point of definition to the end of the file.

Enter details here

106.

What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile?

#include
#define SWAP(a, b, c)(c t; t=a, a=b, b=t)
int main()
{
    int x=10, y=20;
    SWAP(x, y, int);
    printf("%d %d\n", x, y);
    return 0;
}

 

Answer: C

The code won't compile since declaration of t cannot occur within parenthesis.

Enter details here

107.

#include 
#define ISEQUAL(X, Y) X == Y
int main()
{
    #if ISEQUAL(X, 0)
        printf("Geeks");
    #else
        printf("Quiz");
    #endif
    return 0;
}

Output of the above program?

Answer: A

No answer description available for this question.

Enter details here

108.

#include statement must be written __________

Answer: B

Using these directives before main() improves readability.

Enter details here

109.

Preprocessor directive #undef can be used only on a macro that has been #define earlier

Answer: A

No answer description available for this question.

Enter details here

110.

Point out the error in the program

#include
#define SI(p, n, r) float si; si=p*n*r/100;
int main()
{
    float p=2500, r=3.5;
    int n=3;
    SI(p, n, r);
    SI(1500, 2, 2.5);
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

Loading…
Tags: C Preprocessor Questions and Answers || C Preprocessor MCQ Questions and Answers || C Preprocessor GK Questions and Answers || C Preprocessor GK MCQ Questions || C Preprocessor Multiple Choice Questions and Answers || C Preprocessor GK || GK on C Preprocessor || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming