Preprocessor and declarations M8 Test

  1. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA(x, y)  x+y
    
    int main(void){
        int i = -1;
        int i2 = -2;
    
        printf("%d", -ALPHA(i i2));
        return 0;
    }
    • the program outputs -1
    • the program outputs -2
    • the program outputs -3
    • the program outputs 0
  2. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define A(x) ((x)?-1:0)
    #define B(a) !(a)
    
    int main(void) {
        int i = 2;
        int i2 = A(B(i));
    
        printf("%d", i2);
        return 0;
    }
    • the program outputs -1
    • the program outputs -3
    • the program outputs -2
    • the program outputs 0
  3. What happens if you try to compile and run this program?

    #include <stdio.h>
    
    int main(void) {
        int X = 1;
    #define X 1
        int Y = X - 2;
    #undef X
        printf("%d", Y+X);
        return 0;
    }
    • the program outputs -1
    • the program outputs -3
    • the program outputs 0
    • the program outputs -2
  4. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define X 1
    #define y 2
    
    int main(void) {
        int i =
    #if X << Y > 0
        -X
    #else
        -Y
    #endif
        ;
        printf("%d", i);
        return 0;
    }
    • the program outputs -3
    • the program outputs 0
    • the program outputs -2
    • the program outputs -1
  5. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define X 1
    #define y 2
    
    int main(void) {
        int i =
    #if X >> Y > 0
        -X
    #else
        -Y
    #endif
        ;
        printf("%d", i);
        return 0;
    }
    • the program outputs -2
    • the program outputs -1
    • the program outputs 0
    • the program outputs -3
  6. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA -2
    
    int main(void) {
        int i = -1;
    i += ALPHA;
    
            printf("%d", i);
        return 0;
    }
    • the program outputs -3
    • the program outputs -1
    • the program outputs -2
    • the program outputs 0
  7. What happens if you try to compile and run this program?

    #include <stdio.h>
    
    int main(void) {
    #undef X
        int X = 1;
        int Y = X - 2;
    
    #define X -2
        printf("%d",Y+X);
        return 0;
    }
    • the program outputs -1
    • the program outputs -2
    • the program outputs 0
    • the program outputs -3
  8. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA -1+2
    
    int main(void) {
        int i = -1;
        i += ALPHA;
        printf("%d", i);
        return 0;
    }
    • the program outputs -3
    • the program outputs 0
    • the program outputs -1
    • the program outputs -2
  9. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define X 1
    #define y 2
    
    int main(void) {
        int i = -1;
        i = -1 * ALPHA;
    
        printf("%d", i);
        return 0;
    }
    • the program outputs 0
    • the program outputs -3
    • the program outputs -1
    • the program outputs -2
  10. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA(x)    2*-x
    
    int main(void) {
        int i = ALPHA((1-1));
    
        printf("%d", i);
        return 0;
    }
    • the program outputs 0
    • the program outputs -1
    • the program outputs -3
    • the program outputs -2
  11. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define A
    #define C
    
    int main(void) {
        int i =
    #ifdef A 
    #ifdef B
        -1
    #else
        -2
    #endif
    #else
        -3
    #endif
        ;
    
        printf("%d", i);
        return 0;
    }
    • the program outputs -1
    • the program outputs -2
    • the program outputs -3
    • the program outputs 0
  12. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define B
    #define C
    
    int main(void) {
        int i =
    #ifdef A 
    #ifdef C
        -1
    #else
        -2
    #endif
    #else
        -3
    #endif
        ;
    
        printf("%d", i);
        return 0;
    }
    • the program outputs -3
    • the program outputs -1
    • the program outputs -2
    • the program outputs 0
  13. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA(x, y) x##2-y
    
    int main(void) {
        int i = -1;
        int i2 = -2;
    
        printf("%d", ALPHA(i, i2));
        return 0;
    }
    • the program outputs -1
    • the program outputs -2
    • the program outputs 0
    • the program outputs -3
  14. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA -1-2
    
    int main(void) {
        int i = -1;
        i = i * ALPHA;
    
        printf("%d", i);
        return 0;
    }
    • the program outputs -3
    • the program outputs 0
    • the program outputs -2
    • the program outputs -1
  15. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA(x) -x
    
    int main(void) {
        int i = ALPHA(2-1);
        printf("%d", i);
        return 0;
    }
    • the program outputs 0
    • the program outputs -1
    • the program outputs -3
    • the program outputs -1
  16. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define A
    #define C
    
    int main(void) {
        int i =
    #ifdef A
    #ifdef C
        -1
    #endif
    #else
        -3
    #endif
        ;
    
        printf("%d", i);
        return 0;
    }
    • the program outputs -1
    • the program outputs -3
    • the program outputs 0
    • the program outputs -2
  17. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA(x) 2*-x
    
    int main(void) {
        int i = ALPHA(1-);
    
        printf("%d", i);
        return 0;
    }
    • the program outputs -2
    • the program outputs 0
    • the program outputs -3
    • the program outputs -1
  18. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define ALPHA -1
    #define BETA - ALPHA
    
    int main(void) {
        int i = ALPHA + BETA * ALPHA * BETA;
        printf("%d", i);
        return 0;
    }
    • the program outputs -3
    • the program outputs -2
    • the program outputs 0
    • the program outputs -1
  19. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define A(x)  ((x)?-1:0)
    
    int main(void) {
        int i = 2;
        int i2 = A(i) * i;
        printf("%d", i2);
        return 0;
    }
    • the program outputs -2
    • the program outputs -3
    • the program outputs -1
    • the program outputs 0
  20. What happens if you try to compile and run this program?

    #include <stdio.h>
    #define A(x) #x
    
    int main(void) {
        int i = -1;
        char *s = A(i);
        i = -(s[0] == 'i';
    
        printf("%d", i);
        return 0;
    }
    • the program outputs 0
    • the program outputs -3
    • the program outputs -1
    • the program outputs -2
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments