250+ TOP MCQs on Formatted Input and Answers

C helps anyone preparing for Emulex and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Emulex interviews on C Programming language.

Here is a listing of C Objective Questions on “Formatted Input” along with answers, explanations and/or solutions:

1. Which of the following doesn’t require an & for the input in scanf()?
a) char name[10];
b) int name[10];
c) float name[10];
d) all of the mentioned
Answer: a
Clarification: None.

2. Which of the following is an invalid method for input?
a) scanf(“%d%d%d”,&a, &b, &c);
b) scanf(“%d %d %d”, &a, &b, &c);
c) scanf(“Three values are %d %d %d”,&a,&b,&c);
d) none of the mentioned
Answer: d
Clarification: None.

3. Which of the following represents the function for scanf()?
a) void scanf(char *format, …)
b) int scanf(char *format, …)
c) char scanf(int format, …)
d) char *scanf(char *format, …)
Answer: b
Clarification: None.

4. What does scanf() function return?
a) Number of successfully matched and assigned input items
b) Nothing
c) Number of characters properly printed
d) Error
Answer: a
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         int n;
  5.         scanf("%d", n);
  6.         printf("%d", n);
  7.     }

a) Prints the number that was entered
b) Segmentation fault
c) Nothing
d) Varies
Answer: c
Clarification: None.

6. What will be the output of the following C statement?

int sscanf(char *string, char *format, arg1, arg2, …)

a) Scans the string according to the format in format and stores the resulting values through arg1, arg2, etc
b) The arguments arg1,arg2 etc must be pointers
c) Scans the string according to the format in format and stores the resulting values through arg1, arg2, etc, those arguments arg1,arg2 etc must be pointers
d) None of the mentioned
Answer: c
Clarification: None.

7. The conversion characters d, i, o, u, and x may be preceded by h in scanf() to indicate?
a) A pointer to short
b) A pointer to long
c) Nothing
d) Error
Answer: a
Clarification: None.

8. What will be the output of the following C code (when 4 and 5 are entered)?

  1.     #include 
  2.     void main()
  3.     {
  4.         int m, n;
  5.         printf("enter a number");
  6.         scanf("%d", &n);
  7.         scanf("%d", &m);
  8.         printf("%dt%dn", n, m);
  9.     }

a) Error
b) 4 junkvalue
c) Junkvalue 5
d) 4 5
Answer: d
Clarification: None.

  250+ TOP MCQs on Automatic Variables and Answers

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top