Log In Register

Units


Line Input & Output - Questions and Answers

 

Practice these Line Input & Output under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Line Input & Output for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Line Input & Output of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Line Input & Output.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Line Input & Output under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Line Input & Output topic of C Programming:

 

1.

The syntax of fgets is char *fgets(char *line, int maxline, FILE *fp).which is true for     fgets.fgets

Answer: Option A

Explanation:

2.

gets and puts operate on

Answer: Option D

Explanation:

3.

What is the output of this C code if 2 character is typed by the user?

  1.     #include <stdio.h>
  2.     #include <string.h>
  3.     int main()
  4.     {
  5.         char line[3];
  6.         fgets(line, 3, stdin);
  7.         printf("%d\n", line[2]);
  8.         return 0;
  9.     }

Answer: Option B

Explanation:

4.

fputs function writes a string to a file that only ends with a newline.

Answer: Option C

Explanation:

5.

puts does the following when it writes to stdout

Answer: Option A

Explanation:

6.

gets function checks overflow run

Answer: Option C

Explanation:

7.

gets does the following when it reads from stdin

Answer: Option B

Explanation:

8.

The following function
    int fputs(char *line, FILE *fp)
    returns EOF when:

Answer: Option A

Explanation:

9.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #include <string.h>
  3.     int main()
  4.     {
  5.         char line[3];
  6.         FILE *fp;
  7.         fp = fopen("newfile.txt", "r");
  8.         while (fgets(line, 3, fp))
  9.         fputs(line, stdout);
  10.         return 0;
  11.     }

Answer: Option B

Explanation:

10.

What is the size of array “line” used in fgets(line, maxline, *fp) function?

Answer: Option C

Explanation:

11.

Which is true about fputs.fputs returns?

Answer: Option A

Explanation:

12.

Identify X library function for line input and output?

  1.     #include <stdio.h>
  2.     int X(char *s, FILE *iop)
  3.     {
  4.         int c;
  5.         while (c = *s++)
  6.         putc(c, iop);
  7.         return ferror(iop) ? EOF : 0;
  8.     }

Answer: Option B

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #include <string.h>
  3.     int main()
  4.     {
  5.         char line[3];
  6.         fgets(line, 3, stdin);
  7.         printf("%d\n", strlen(line));
  8.         return 0;
  9.     }

Answer: Option C

Explanation:

14.

puts function adds newline character

Answer: Option D

Explanation:

15.

Which of the following is the right declaration for fgets inside the library?

Answer: Option C

Explanation: