Languages [HCL Placement]: Sample Questions 5 - 6 of 13

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 5

Question

MCQ▾

What are the values printed by the following program?

  1. #definedprint(expr) printf(#expr"=%dn",expr)
  2. main()
  3. {
  4.     intx=7;
  5.     inty=3;
  6.     dprintf(x/y);
  7. }

Choices

Choice (4)

a.

= 2

b.

#2 = 2

c.

expr = 2

d.

All of the above

Answer

a.

Explanation

  • In the main () function two integers are initialized, i.e.. x = 7, y = 3
  • In the dprintf function we are passing x/y as expr.
  • In that function we want to print the value of expr.
  • Here, as x = 7 and y = 3 and both are integer variables their division will also result in an integer.
  • Here, % d is the format specifier of integer.
  • results into 2.333333 … but as variables and result is integer it will be 2 only.
  • So, output will be .

Question 6

Question

MCQ▾

Which of the following about the following two declarations is true?

i) int ⚹ F ()

ii) int (⚹ F) ()

Choices

Choice (4)

a.

The first declaration is a function returning a pointer to an integer and the second is a pointer to function returning int

b.

i & ii are identical

c.

i & ii are different ways of declaring pointer to a function

d.

The first is a correct declaration and the second is wrong

Answer

a.

Explanation

In the first statement one function F is returning to a pointer which is returning an integer value. In the second statement, pointer F is returning to a function which is again returning to an integer value. Both declarations are different from each other, but both are correct.

Developed by: