logo

CuriousTab

CuriousTab

Discussion


Home C Programming Bitwise Operators See What Others Are Saying!
  • Question
  • What will be the output of the program?
    #include<stdio.h>
    
    int main()
    {
        unsigned char i = 0x80;
        printf("%d\n", i<<1);
        return 0;
    }
    


  • Options
  • A. 0
  • B. 256
  • C. 100
  • D. 80

  • Correct Answer
  • 256 


  • More questions

    • 1. In a macro call the control is passed to the macro.

    • Options
    • A. True
    • B. False
    • Discuss
    • 2. What will be the output of the program under DOS?
      #include<stdio.h>
      
      int main()
      {
          char huge *near *far *ptr1;
          char near *far *huge *ptr2;
          char far *huge *near *ptr3;
          printf("%d, %d, %d\n", sizeof(ptr1), sizeof(**ptr2), sizeof(ptr3));
          return 0;
      }
      

    • Options
    • A. 4, 4, 4
    • B. 4, 2, 2
    • C. 2, 8, 4
    • D. 2, 4, 8
    • Discuss
    • 3. What will be the output of the program?
      #include<stdio.h>
      #define SQR(x)(x*x)
      
      int main()
      {
          int a, b=3;
          a = SQR(b+2);
          printf("%d\n", a);
          return 0;
      }
      

    • Options
    • A. 25
    • B. 11
    • C. Error
    • D. Garbage value
    • Discuss
    • 4. Point out the error in the program.
      #include<stdio.h>
      const char *fun();
      
      int main()
      {
          *fun() = 'A';
          return 0;
      }
      const char *fun()
      {
          return "Hello";
      }
      

    • Options
    • A. Error: RValue required
    • B. Error: Lvalue required
    • C. Error: fun() returns a pointer const character which cannot be modified
    • D. No error
    • Discuss
    • 5. Which statement will you add to the following program to ensure that the program outputs "CuriousTab" on execution?
      #include<stdio.h>
      
      int main()
      {
          char s[] = "CuriousTab";
          char t[25];
          char *ps, *pt;
          ps = s;
          pt = t;
          while(*ps)
              *pt++ = *ps++;
      
          /* Add a statement here */
          printf("%s\n", t);
          return 0;
      }
      

    • Options
    • A. *pt='';
    • B. pt='\0';
    • C. pt='\n';
    • D. *pt='\0';
    • Discuss
    • 6. A float occupies 4 bytes. If the hexadecimal equivalent of these 4 bytes are A, B, C and D, then when this float is stored in memory in which of the following order do these bytes gets stored?

    • Options
    • A. ABCD
    • B. DCBA
    • C. 0xABCD
    • D. Depends on big endian or little endian architecture
    • Discuss
    • 7. To print out a and b given below, which of the following printf() statement will you use?
      #include<stdio.h>
      
      float a=3.14;
      double b=3.14;
      

    • Options
    • A. printf("%f %lf", a, b);
    • B. printf("%Lf %f", a, b);
    • C. printf("%Lf %Lf", a, b);
    • D. printf("%f %Lf", a, b);
    • Discuss
    • 8. Which of the following function is more appropriate for reading in a multi-word string?

    • Options
    • A. printf();
    • B. scanf();
    • C. gets();
    • D. puts();
    • Discuss
    • 9. What will be the output of the program if the array begins at address 65486?
      #include<stdio.h>
      
      int main()
      {
          int arr[] = {12, 14, 15, 23, 45};
          printf("%u, %u\n", arr, &arr);
          return 0;
      }
      

    • Options
    • A. 65486, 65488
    • B. 65486, 65486
    • C. 65486, 65490
    • D. 65486, 65487
    • Discuss
    • 10. What will be the output of the program in Turbo C (under DOS)?
      #include<stdio.h>
      
      int main()
      {
          struct emp
          {
              char *n;
              int age;
          };
          struct emp e1 = {"Dravid", 23};
          struct emp e2 = e1;
          strupr(e2.n);
          printf("%s\n", e1.n);
          return 0;
      }
      

    • Options
    • A. Error: Invalid structure assignment
    • B. DRAVID
    • C. Dravid
    • D. No output
    • Discuss


    Comments

    There are no comments.

Enter a new Comment