logo

CuriousTab

CuriousTab

Discussion


Home C Programming Structures, Unions, Enums See What Others Are Saying!
  • Question
  • What will be the output of the program?
    #include<stdio.h>
    
    int main()
    {
        enum status {pass, fail, absent};
        enum status stud1, stud2, stud3;
        stud1 = pass;
        stud2 = absent;
        stud3 = fail;
        printf("%d %d %d\n", stud1, stud2, stud3);
        return 0;
    }
    


  • Options
  • A. 0, 1, 2
  • B. 1, 2, 3
  • C. 0, 2, 1
  • D. 1, 3, 2

  • Correct Answer
  • 0, 2, 1 


  • More questions

    • 1. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int i=2;
          printf("%d, %d\n", ++i, ++i);
          return 0;
      }
      

    • Options
    • A. 3, 4
    • B. 4, 3
    • C. 4, 4
    • D. Output may vary from compiler to compiler
    • Discuss
    • 2. What will be the output of the program?
      #include<stdio.h>
      #include<stdlib.h>
      
      int main()
      {
          char *i = "55.555";
          int result1 = 10;
          float result2 = 11.111;
          result1 = result1+atoi(i);
          result2 = result2+atof(i);
          printf("%d, %f", result1, result2);
          return 0;
      }
      

    • Options
    • A. 55, 55.555
    • B. 66, 66.666600
    • C. 65, 66.666000
    • D. 55, 55
    • Discuss
    • 3. On left shifting, the bits from the left are rotated and brought to the right and accommodated where there is empty space on the right?

    • Options
    • A. True
    • B. False
    • Discuss
    • 4. What is (void*)0?

    • Options
    • A. Representation of NULL pointer
    • B. Representation of void pointer
    • C. Error
    • D. None of above
    • Discuss
    • 5. Bitwise & and | are unary operators

    • Options
    • A. True
    • B. False
    • Discuss
    • 6. Point out the error in the program.
      #include<stdio.h>
      const char *fun();
      
      int main()
      {
          char *ptr = fun();
          return 0;
      }
      const char *fun()
      {
          return "Hello";
      }
      

    • Options
    • A. Error: Lvalue required
    • B. Error: cannot convert 'const char *' to 'char *'.
    • C. No error and No output
    • D. None of above
    • Discuss
    • 7. In a function that receives variable number of arguments the fixed arguments passed to the function can be at the end of argument list.

    • Options
    • A. True
    • B. False
    • Discuss
    • 8. Point out the error in the following program.
      #include<stdio.h>
      #include<stdarg.h>
      
      int main()
      {
          void display(char *s, int num1, int num2, ...);
          display("Hello", 4, 2, 12.5, 13.5, 14.5, 44.0);
          return 0;
      }
      void display(char *s, int num1, int num2, ...)
      {
          double c;
          char s;
          va_list ptr;
          va_start(ptr, s);
          c = va_arg(ptr, double);
          printf("%f", c);
      }
      

    • Options
    • A. Error: invalid arguments in function display()
    • B. Error: too many parameters
    • C. Error: in va_start(ptr, s);
    • D. No error
    • Discuss
    • 9. Point out the error if any in the following program (Turbo C).
      #include<stdio.h>
      #include<stdarg.h>
      void display(int num, ...);
      
      int main()
      {
          display(4, 'A', 'a', 'b', 'c');
          return 0;
      }
      void display(int num, ...)
      {
          char c; int j;
          va_list ptr;
          va_start(ptr, num);
          for(j=1; j<=num; j++)
          {
              c = va_arg(ptr, char);
              printf("%c", c);
          }
      }
      

    • Options
    • A. Error: unknown variable ptr
    • B. Error: Lvalue required for parameter
    • C. No error and print A a b c
    • D. No error and print 4 A a b c
    • Discuss
    • 10. Point out the error in the following program.
      #include<stdio.h>
      #include<stdarg.h>
      void varfun(int n, ...);
      
      int main()
      {
          varfun(3, 7, -11, 0);
          return 0;
      }
      void varfun(int n, ...)
      {
          va_list ptr;
          int num;
          num = va_arg(ptr, int);
          printf("%d", num);
      }
      

    • Options
    • A. Error: ptr has to be set at begining
    • B. Error: ptr must be type of va_list
    • C. Error: invalid access to list member
    • D. No error
    • Discuss


    Comments

    There are no comments.

Enter a new Comment