Top

C Preprocessor

51.

Which of the following is not a preprocessor directive?

Answer: D

#ifelse is not a preprocessor directive. #error, #pragma, #if are preprocessor directives. There is a preprocessor directive, #elif, which performs the function of else-if.

Enter details here

52.

Consider the following statements

#define hypotenuse (a, b) sqrt (a*a+b*b); 

The macro call hypotenuse(a+2,b+3);

Answer: D

No answer description available for this question.

Enter details here

53.

What will be the output of the program?

#include
#define JOIN(s1, s2) printf("%s=%s %s=%s \n", #s1, s1, #s2, s2);
int main()
{
    char *str1="India";
    char *str2="BIX";
    JOIN(str1, str2);
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

54.

What is the output of this program?

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

 

Answer: B

The preprocessor directives can be redefined anywhere in the program. So the most recently assigned value (#define i 10) will be taken.

Enter details here

55.

_______________ is the preprocessor directive which is used to end the scope of #ifdef.

Answer: C

The #ifdef preprocessor directive is used to check if a particular identifier is currently defined or not. If the particular identifier is defined, the statements following this preprocessor directive are executed till another preprocessor directive #endif is encountered. #endif is used to end the scope of #ifdef.

Enter details here

56.

What will be the output of the following C code?

#include
void f()
{
    #define sf 100
    printf("%d",sf);
}
int main()
{
    #define sf 99;
    f();
    printf("%d",sf);
}

 

Answer: A

Macro definition is global even if it is appears within the function scope. In this case the macro sf is defined in the function f(). Hence it results in a compile time error.

Enter details here

Answer: D

The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control.

Enter details here

58.

What is the output of following program?

#include 
#define macro(n, a, i, m) m##a##i##n
#define MAIN macro(n, a, i, m)
 
int MAIN()
{
    printf("GeeksQuiz");
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

59.

Will the program compile successfully?

#include

int main()
{
    #ifdef NOTE
        int a;
        a=10;
    #else
        int a;
        a=20;
    #endif
    printf("%d\n", a);
    return 0;
}

 

Answer: A

No answer description available for this question.

Enter details here

60.

Point out the error in the program

#include

int main()
{
    int i;
    #if A
        printf("Enter any number:");
        scanf("%d", &i);
    #elif B
        printf("The number is odd");
    return 0;
}

 

Answer: A

The conditional macro #if must have an #endif. In this program there is no #endif statement written.

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