Redpine Infotech Papers: Sample Questions 15 - 16 of 19

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

Question number: 15

» Languages » C & C Plus Plus

MCQ▾

Question

What is output for the following program?

  1. #include<stdio.h>
  2. main ()
  3. {
  4.     unsigned char i;
  5.     for(i=0i<300i++)
  6.     {
  7.         printf (“*”);
  8.     }
  9. }

Choices

Choice (4) Response

a.

299

b.

Infinite

c.

300

d.

Question does not provide sufficient data or is vague

Answer

b.

Explanation

Table shows the program

Table shows the program

#include < tdio. h >

Standard library function

main ()

startup after initialization

unsigned char i;

Size of character variable is 8 byte. Thus, the range of unsigned number in 8 bits is from 0 to

for (i = 0; i < 300; i++)

This loop upto 299 starting from 0, executing the statements in the loop 299 times. After executing these, the variable “i” is incremented by 1. However since the unsigned char cannot reach 300, the final incremented number is 0, resulting in re-execution of the loop. That is the loop runs infinite times.

printf (“*”);

Print * infinite time.

Question number: 16

» Basic CS » Algorithms

MCQ▾

Question

evaluates 18 then

  1. –left associative * has precedence over-
  2. –right associative * has precedence over-
  3. *left associative - has precedence over *
  4. *right associative - has precedence over*

Which is correct?

Choices

Choice (4) Response

a.

1

b.

2

c.

3

d.

4

Answer

d.

Explanation

Given,

Evaluates 18

Then,

Image of the Algorithms

Image of the Algorithms

Image of the Algorithms

- has precedence over * and it associates from the right.