logo

CuriousTab

CuriousTab

Discussion


Home C Programming Library Functions See What Others Are Saying!
  • Question
  • What is the purpose of fflush() function.


  • Options
  • A. flushes all streams and specified streams.
  • B. flushes only specified stream.
  • C. flushes input/output buffer.
  • D. flushes file buffer.

  • Correct Answer
  • flushes all streams and specified streams. 

    Explanation
    "fflush()" flush any buffered output associated with filename, which is either a file opened for writing or a shell command for redirecting output to a pipe or coprocess.
    Example:
    fflush(FilePointer);
    fflush(NULL); flushes all streams.

    More questions

    • 1. va_list is an array that holds information needed by va_arg and va_end

    • Options
    • A. True
    • B. False
    • Discuss
    • 2. A structure can contain similar or dissimilar elements

    • Options
    • A. True
    • B. False
    • Discuss
    • 3. Which of the statements is correct about the program?
      #include<stdio.h>
      
      int main()
      {
          float a=3.14;
          char *j;
          j = (char*)&a;
          printf("%d\n", *j);
          return 0;
      }
      

    • Options
    • A. It prints ASCII value of the binary number present in the first byte of a float variable a.
    • B. It prints character equivalent of the binary number present in the first byte of a float variable a.
    • C. It will print 3
    • D. It will print a garbage value
    • Discuss
    • 4. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int i=4;
          switch(i)
          {
              default:
                 printf("This is default\n");
              case 1:
                 printf("This is case 1\n");
                 break;
              case 2:
                 printf("This is case 2\n");
                 break;
              case 3:
                 printf("This is case 3\n");
          }
          return 0;
      }
      

    • Options
    • A. This is default
      This is case 1
    • B. This is case 3
      This is default
    • C. This is case 1
      This is case 3
    • D. This is default
    • Discuss
    • 5. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int a = 300, b, c;
          if(a >= 400)
              b = 300;
          c = 200;
          printf("%d, %d, %d\n", a, b, c);
          return 0;
      }
      

    • Options
    • A. 300, 300, 200
    • B. Garbage, 300, 200
    • C. 300, Garbage, 200
    • D. 300, 300, Garbage
    • Discuss
    • 6. What will be the output of the program?
      #include<stdio.h>
      int main()
      {
          int x = 10, y = 20;
          if(!(!x) && x)
              printf("x = %d\n", x);
          else
              printf("y = %d\n", y);
          return 0;
      }
      

    • Options
    • A. y =20
    • B. x = 0
    • C. x = 10
    • D. x = 1
    • Discuss
    • 7. Which of the following correctly represents a long double constant?

    • Options
    • A. 6.68
    • B. 6.68L
    • C. 6.68f
    • D. 6.68LF
    • Discuss
    • 8. 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
    • Discuss
    • 9. Point out the error in the program?
      #include<stdio.h>
      
      int main()
      {
          struct emp
          {
              char name[20];
              float sal;
          };
          struct emp e[10];
          int i;
          for(i=0; i<=9; i++)
              scanf("%s %f", e[i].name, &e[i].sal);
          return 0;
      }
      

    • Options
    • A. Error: invalid structure member
    • B. Error: Floating point formats not linked
    • C. No error
    • D. None of above
    • Discuss
    • 10. If the following structure is written to a file using fwrite(), can fread() read it back successfully?
      struct emp
      {
          char *n;
          int age;
      };
      struct emp e={"CuriousTab", 15};
      FILE *fp;
      fwrite(&e, sizeof(e), 1, fp);
      

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


    Comments

    There are no comments.

Enter a new Comment