Sasken Papers: Sample Questions 33 - 34 of 35

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 33

» Aptitude

Short Answer Question▾

Write in Short

  1. int ( *P[10]) ();

In above declaration what type of variable is P?

Explanation

  • P is array of pointers that each points to a function that takes no arguments and returns an integer
  • Here, P is a pointer to an array of 10 integers.
  • An array is a collection of similar elements. An array is similar to an ordinary variable except that it can store multiple elements of similar data type. Array elements are stored in contiguous memory locations and so they can be accessed using pointers. To know the address of any element of array we need to use “address of” operator (&). To know the value of any element of array we need to use “value at address” operator (*).

Question number: 34

» Aptitude

MCQ▾

Question

What will be the output of the following program?

  1. main ()
  2. {
  3.     int I = 3;
  4.     while (I--)
  5.     {
  6.         int I = 100;
  7.         I--;
  8.         printf (-%dI);
  9.     }
  10. }

Choices

Choice (4) Response

a.

Error

b.

100 99 98

c.

99 98 97

d.

99 99 99

Answer

d.

Explanation

  • In the main () function one integer variable i initialized with 3. The while () loop gets executed till the condition is true. Here, i– is passed in the while loop. i– is the post decremet operator. So, first while (3) will be executed as 3 > 0.
  • Here, again i is initialized with new value 100. i– = 99. So, when control reaches to printf () function 99 will be printed on new line of the output screen. Now value of i is decremented by 1 and becomes 2. So, while (2) gets executed as 2 > 0.
  • Here, again i is initialized with new value 100. i– = 99. So, when control reaches to printf () function 99 will be printed on new line of the output screen. Now value of i is decremented by 1 and becomes 1. Still 1 > 0 so while (1) gets executed as 2 > 0.
  • Here, again i is initialized with new value 100. i– = 99. So, when control reaches to printf () function 99 will be printed on new line of the output screen.