C MCQ set number 00702

1. What does this statement printf(“%10s”, state); means?
a) 10 spaces before the string state is printed
b) Print empty spaces if the string state is less than 10 characters
c) Print the last 10 characters of the string
d) None of the mentioned

Answer

Answer: b [Reason:] None.

2. What are the Properties of first argument of a printf functions?
a) It is defined by user
b) It keeps the record of the types of arguments that will follow
c) There may no be first argument
d) None of the mentioned

Answer

Answer: b [Reason:] None.

3. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 10, j = 2;
  5.         printf("%dn", printf("%d %d ", i, j));
  6.     }

a) Compile time error
b) 10 2 4
c) 10 2 2
d) 10 2 5

Answer

Answer: d [Reason:] None.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 10, j = 3;
  5.         printf("%d %d %d", i, j);
  6.     }

a) Compile time error
b) 10 3
c) 10 3 some garbage value
d) Undefined behaviour

Answer

Answer: c [Reason:] None.

5. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int i = 10, j = 3, k = 3;
  5.         printf("%d %d ", i, j, k);
  6.     }

a) Compile time error
b) 10 3 3
c) 10 3
d) 10 3 somegarbage value

Answer

Answer: c [Reason:] None.

6. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char *s = "myworld";
  5.         int i = 9;
  6.         printf("%*s", i, s);
  7.     }

a) myworld
b) myworld(note: spaces to the left of myworld)
c) myworld (note:followed by two spaces after myworld)
d) Undefined

Answer

Answer: b [Reason:] None.

7. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main(int argc, char **argv)
  3.     {
  4.         char *s = "myworld";
  5.         int i = 3;
  6.         printf("%10.*s", i, s);
  7.     }

a) myw
b) myworld(note:2 spaces before myworld)
c) myworld (note:2 spaces after myworld)
d) myw(note:6 spaces after myworld)

Answer

Answer: d [Reason:] None.

8. What is the difference between %e and %g ?
a) %e output formatting depends on the argument and %g always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional.
b) %e always formats in the format [-]m.dddddd or [-]m.dddddE[+|-]xx where no.of ds are optional and output formatting depends on the argument.
c) No differences
d) Depends on the standard

Answer

Answer: b [Reason:] None.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.