3i Infotech Papers: Sample Questions 546 - 548 of 1245

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

Question number: 546

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What is the output of the following program?

  1. void main ()
  2. {
  3.     while (1)
  4.     {
  5.         if (printf ( “%d” printf ( “%d” ) ) )
  6.         break;
  7.         else
  8.         continue;
  9.     }
  10. }

Explanation

In the program

Table shows the program

Table shows the program

while (1)

{

if (printf (“%d” printf (“%d”) ) )

break;

else

continue;

}

The inner printf executes first to print some garbage values.

The printf returns no of characters printed and this value also cannot be predicted.

Still the outer printf prints something and so returns a non-zero value.

So, it encounters the break statement and comes out of the while statements.

Question number: 547

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

  1. #include<studio.h>
  2. main ()
  3. {
  4.     int i = 1j = 2;
  5.     switch (i)
  6.     {
  7.         case 1Printf ( “GOOD” );
  8.         break;
  9.         case jPrintf ( “BAD” );
  10.         break;
  11.     }
  12. }

Explanation

  • In a program

Table shows the program

Table shows the program

int i = 1, j = 2;

Define the integer variables i and j

  1. switch (i)
  2. {
  3.     case 1Printf ( “GOOD” );
  4.     break;
  5.     case jPrintf ( “BAD” );
  6.     break;
  7. }

Given the switch case

Here the case statement can have only constant expressions

(this implies that we cannot use variable names directly so an error)

  • So the answer is Compiler error: Constant expression required in function main.

  • NOTE: Enumerated types can be used in case statements.

Question number: 548

» Basic CS » Networks

Essay Question▾

Describe in Detail

What is RIP (Routing Information Protocol)?

Explanation

  • RIP is one of the oldest distance-vector routing protocol employing hop count routing metric- Hop is the step towards the next existing device- a router, computer or any device

  • Used for exchanging information between the routers.

  • Simple vector routing protocol with many existing implementations

  • Used in both local and wide area networks

  • Easily configured and implemented.

How Does RIP Work?

  • Each router initializes its routing table with a list of locally connected networks.

  • Every router advertises the contents of its routing table over all the RIP enabled interfaces.

  • Each route has a property called a metric indicating “distance” to the route’s destination.

  • When router detects change in routing table- it sends an immediate “triggered” update.

  • Request message allows a newly started router to rapidly query all of its neighbour’s routing tables.

  • When router “A” learns a route from router “B” it advertises the route back to “B” with a metric of 16 ensuring that “B” is never under the impression that “A” has a different way of getting to the same destination.