logo

CuriousTab

CuriousTab

Discussion


Home C Programming Bitwise Operators Comments

  • Question
  • What will be the output of the program?
    #include<stdio.h>
    
    int main()
    {
        int i=4, j=8;
        printf("%d, %d, %d\n", i|j&j|i, i|j&&j|i, i^j);
        return 0;
    }
    


  • Options
  • A. 4, 8, 0
  • B. 1, 2, 1
  • C. 12, 1, 12
  • D. 0, 0, 0

  • Correct Answer
  • 12, 1, 12 


  • Bitwise Operators problems


    Search Results


    • 1. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char c=48;
          int i, mask=01;
          for(i=1; i<=5; i++)
          {
              printf("%c", c|mask);
              mask = mask<<1;
          }
          return 0;
      }
      

    • Options
    • A. 12400
    • B. 12480
    • C. 12500
    • D. 12556
    • Discuss
    • 2. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          unsigned int res;
          res = (64 >>(2+1-2)) & (~(1<<2));
          printf("%d\n", res);
          return 0;
      }
      

    • Options
    • A. 32
    • B. 64
    • C. 0
    • D. 128
    • Discuss
    • 3. Assuming, integer is 2 byte, What will be the output of the program?
      #include;
      
      int main()
      {
          printf("%x\n", -1>>1);
          return 0;
      }
      

    • Options
    • A. ffff
    • B. 0fff
    • C. 0000
    • D. fff0
    • Discuss
    • 4. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          printf("%%%%\n");
          return 0;
      }
      

    • Options
    • A. %%%%%
    • B. %%
    • C. No output
    • D. Error
    • Discuss
    • 5. What will be the output of the program?
      #include<stdio.h>
      char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}";
      
      int main()
      {
          printf(str, 34, str, 34);
          return 0;
      }
      

    • Options
    • A. char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}"; main(){ printf(str, 34, str, 34);}
    • B. char *str = %c%s%c; main(){ printf(str, 34, str, 34);}
    • C. No output
    • D. Error in program
    • Discuss
    • 6. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          int i=32, j=0x20, k, l, m;
          k=i|j;
          l=i&j;
          m=k^l;
          printf("%d, %d, %d, %d, %d\n", i, j, k, l, m);
          return 0;
      }
      

    • Options
    • A. 0, 0, 0, 0, 0
    • B. 0, 32, 32, 32, 32
    • C. 32, 32, 32, 32, 0
    • D. 32, 32, 32, 32, 32
    • Discuss
    • 7. If an unsigned int is 2 bytes wide then, What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          unsigned int a=0xffff;
          ~a;
          printf("%x\n", a);
          return 0;
      }
      

    • Options
    • A. ffff
    • B. 0000
    • C. 00ff
    • D. ddfd
    • Discuss
    • 8. If an unsigned int is 2 bytes wide then, What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          unsigned int m = 32;
          printf("%x\n", ~m);
          return 0;
      }
      

    • Options
    • A. ffff
    • B. 0000
    • C. ffdf
    • D. ddfd
    • Discuss
    • 9. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          printf("%d >> %d %d >> %d\n", 4 >> 1, 8 >> 1);
          return 0;
      }
      

    • Options
    • A. 4 1 8 1
    • B. 4 >> 1 8 >> 1
    • C. 2 >> 4 Garbage value >> Garbage value
    • D. 2 4
    • Discuss
    • 10. What will be the output of the program?
      #define P printf("%d\n", -1^~0);
      #define M(P) int main()\
                   {\
                      P\
                      return 0;\
                   }
      M(P)
      

    • Options
    • A. 1
    • B. 0
    • C. -1
    • D. 2
    • Discuss


    Comments

    There are no comments.

Enter a new Comment