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>
    #include<stdlib.h>
    
    int main()
    {
        int i=0;
        i++;
        if(i<=5)
        {
            printf("CuriousTab");
            exit(1);
            main();
        }
        return 0;
    }
    


  • Options
  • A. Prints "CuriousTab" 5 times
  • B. Function main() doesn't calls itself
  • C. Infinite loop
  • D. Prints "CuriousTab"

  • Correct Answer
  • Prints "CuriousTab" 

    Explanation
    Step 1: int i=0; The variable i is declared as in integer type and initialized to '0'(zero).

    Step 2: i++; Here variable i is increemented by 1. Hence i becomes '1'(one).

    Step 3: if(i<=5) becomes if(1 <=5). Hence the if condition is satisfied and it enter into if block statements.

    Step 4: printf("CuriousTab"); It prints "CuriousTab".

    Step 5: exit(1); This exit statement terminates the program execution.

    Hence the output is "CuriousTab".


    More questions

    • 1. A function that receives variable number of arguments should use va_arg() to extract the last argument from the variable argument list.

    • Options
    • A. True
    • B. False
    • Discuss
    • 2. Bitwise & can be used to check if more than one bit in a number is on.

    • Options
    • A. True
    • B. False
    • Discuss
    • 3. The preprocessor can trap simple errors like missing declarations, nested comments or mismatch of braces.

    • Options
    • A. True
    • B. False
    • Discuss
    • 4. It is necessary that a header files should have a .h extension?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 5. Bitwise | can be used to set multiple bits in number.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 6. Bitwise & can be used to check if a bit in number is set or not.

    • Options
    • A. True
    • B. False
    • Discuss
    • 7. A pointer union CANNOT be created

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 8. What will be the output of the program?
      #include<stdio.h>
      #include<stdlib.h>
      
      int main()
      {
          union test
          {
              int i;
              float f;
              char c;
          };
          union test *t;
          t = (union test *)malloc(sizeof(union test));
          t->f = 10.10f;
          printf("%f", t->f);
          return 0;
      }
      

    • Options
    • A. 10
    • B. Garbage value
    • C. 10.100000
    • D. Error
    • Discuss
    • 9. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int x=4, y, z;
          y = --x;
          z = x--;
          printf("%d, %d, %d\n", x, y, z);
          return 0;
      }
      

    • Options
    • A. 4, 3, 3
    • B. 4, 3, 2
    • C. 3, 3, 2
    • D. 2, 3, 3
    • Discuss
    • 10. Functions cannot return a floating point number

    • Options
    • A. Yes
    • B. No
    • Discuss


    Comments

    There are no comments.

Enter a new Comment