logo

CuriousTab

CuriousTab

Discussion


Home C Programming Functions See What Others Are Saying!
  • Question
  • What will be the output of the program?
    #include<stdio.h>
    void fun(int);
    typedef int (*pf) (int, int);
    int proc(pf, int, int);
    
    int main()
    {
        int a=3;
        fun(a);
        return 0;
    }
    void fun(int n)
    {
        if(n > 0)
        {
            fun(--n);
            printf("%d,", n);
            fun(--n);
        }
    }
    


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

  • Correct Answer
  • 0, 1, 2, 0, 


  • More questions

    • 1. What will be the output of the program in Turb C (under DOS)?
      #include<stdio.h>
      
      int main()
      {
          int arr[5], i=0;
          while(i<5)
              arr[i]=++i;
      
          for(i=0; i<5; i++)
              printf("%d, ", arr[i]);
      
          return 0;
      }
      

    • Options
    • A. 1, 2, 3, 4, 5,
    • B. Garbage value, 1, 2, 3, 4,
    • C. 0, 1, 2, 3, 4,
    • D. 2, 3, 4, 5, 6,
    • Discuss
    • 2. If the binary eauivalent of 5.375 in normalised form is 0100 0000 1010 1100 0000 0000 0000 0000, what will be the output of the program (on intel machine)?
      #include<stdio.h>
      #include<math.h>
      int main()
      {
          float a=5.375;
          char *p;
          int i;
          p = (char*)&a;
          for(i=0; i<=3; i++)
              printf("%02x\n", (unsigned char)p[i]);
          return 0;
      }
      

    • Options
    • A. 40 AC 00 00
    • B. 04 CA 00 00
    • C. 00 00 AC 40
    • D. 00 00 CA 04
    • Discuss
    • 3. 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
    • 4. 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
    • 5. 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
    • 6. What is (void*)0?

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

    • Options
    • A. True
    • B. False
    • Discuss
    • 8. 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
    • 9. 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
    • 10. 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


    Comments

    There are no comments.

Enter a new Comment