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.

Compilation error

Answer: Option C

Explanation:

2.

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

Answer: Option C

Explanation:

3.

gets does the following when it reads from stdin

Answer: Option B

Explanation:

4.

gets function checks overflow run

Answer: Option C

Explanation:

5.

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

Answer: Option A

Explanation:

6.

puts function adds newline character

Answer: Option D

Explanation:

7.

Which function has a return type as char pointer?

Answer: Option A

Explanation:

8.

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:

9.

puts does the following when it writes to stdout

Answer: Option A

Explanation:

10.

gets and puts operate on

Answer: Option D

Explanation:

11.

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

Answer: Option C

Explanation:

12.

Which is true about fputs.fputs returns?

Answer: Option A

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.

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:

15.

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: