3i Infotech Papers: Sample Questions 577 - 578 of 1245

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

Question number: 577

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What is the output of the following program?

  1. main ()
  2. {
  3.     char * p;
  4.     int * q;
  5.     long * r;
  6.     p = q = r = 0;
  7.     p + +;
  8.     q + +;
  9.     r + +;
  10.     printf ( “%p…%p…%p” pqr);
  11. }

Explanation

  • In the program

Table shows the program

Table shows the program

char * p;

int * q;

long * r;

Declare the character pointer p, integer pointer q and long pointer r.

p = q = r = 0;

Define the p, q and r as 0

p ++;

q ++;

r ++;

Increment the value of p, q and r

printf (“%p…%p…%p” p, q, r);

++ operator when applied to pointers increments address according to their corresponding data-types.

  • So the answer is p = 0001, q = 0002 and r = 0004

  • %p print out a pointer, specifically the address to which the pointer refers, and since it is printing out a part computer’s architecture, it does so in hexadecimal.

Question number: 578

» Operating System » Unix

Essay Question▾

Describe in Detail

Difference between the fork () and vfork () system call?

Explanation

Difference between the fork () and vfork ()

Difference between the fork () and vfork ()

fork ()

vfork ()

Separate address space of child process and parent.

Same address space of child process and parent process.

Parent and child process execute simultaneously.

Parent process remains suspended till child process completes its execution.

If the child process alters any page in the address space, it is invisible to the parent process as the address space are separate

If child process alters any page in the address space, it is visible to the parent process as they share the same address space.

fork () uses copy-on-write as an alternative where the parent and child share same pages until any one of them modifies the shared page.

vfork () does not use copy-on-write.