Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 270 - 271 of 354

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

Question 270

C & C Plus Plus

Describe in Detail


What do you meant by active and passive objects?


  • Active Objects:-
    • Active objects instigates a threaded interaction responsible for handling control to other objects that is it is a client.
    • For objects implemented as parallel processes the internal object state may be changed by the object itself and not simply by external calls.
  • Passive Objects:-
    • Passive objects passively wait for the message to be processed waiting for request from another object for its services, that is it is a server.
    • The object is implemented as a parallel process with entry points corresponding to object operations. If no calls are made to it, the object suspends itself.

Question 271

C & C Plus Plus

Describe in Detail

  1. main ()
  2. {
  3.     char ⚹q;
  4.     intj;
  5.     for (j =0; j<3; j ++ )
  6.     scanf (%s (q +j), );
  7.     for (j =0; j<3; j ++ )
  8.     printf (%c, ⚹(q +j) );
  9.     for (j =0; j<3; j ++ )
  10.     printf (%s (q +j), );
  11. }


  • In a program we have only one pointer to type char and since we take input in the same pointer thus we keep writing over in the same location, each time shifting the pointer value by 1.
  • Suppose the inputs are MOUSE, TRACK and VIRTUAL.
  • Then for the first input suppose the pointer starts at location 100 then the input one is stored as

    M O U S E ⧵0

  • When the second input is given the pointer is incremented as j value becomes 1, so the input is filled in memory starting from 101.

    M T R A C K ⧵0

  • The third input starts filling from the location 102

M T V I R T U A L ⧵0

Table Showing the Program
printf (% c, ⚹ (q + j) ) ;The first printf prints the values at the position q, q + 1 and q + 2 = M T V
printf (% s (q + j) ,) ;The second printf prints three strings starting from locations q, q + 1, q + 2, i.e.. MTVIRTUAL, TVIRTUAL and VIRTUAL.

Developed by: