# 3i Infotech Papers: Sample Questions 596 - 597 of 1245

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

## Question number: 596

Essay Question▾

### Describe in Detail

What is the output of the following program?

1. `main ()`
2. `{`
3. `    void swap ();`
4. `    int x = 10, y = 8;`
5. `    swap (&x, &y);`
6. `    printf ( “x = %d y = %d”, x, y);`
7. `}`
8. `void swap ()`
9. `int * a, int * b`
10. `{`
11. `    *a^=*b,*b^=*a,*a^=*b;`
12. `}`

### Explanation

In the program using ^ swaps two variables without using a temporary variable and that too in a single statement.

 void swap (); Swap is a function Take any number of arguments and returns nothing. int x = 10, y = 8; Define integer variable x = 10 and y = 8 swap (&x, &y); Call swap (&x, &y); that has two arguments. printf (“x =%d y =%d”, x, y); printf prints the swapping value of x and y Modern style of declaration: void swap (int * a, int * b) { *a^=*b, *b^=*a, *a^=*b; } void swap () int * a, int * b { *a^=*b, *b^=*a, *a^=*b; } This convention is historic pre-ANSI style (referred to as Kernighan and Ritchie style) style of function declaration. Swap function is defined with arguments following the (). So the declaration for swap looks void swap () which means the swap can take any number of arguments.

## Question number: 597

Essay Question▾

### Describe in Detail

What is time-stamping?

### Explanation

• Time-stamping is the technique proposed by lamppost to order events in a distributed system without the use of clocks.

• Scheme is used to order events consisting of the transmission of messages.

• Any event or activity can have its timestamp recorded, depending on the needs of the user or the capabilities of the system process creating the timestamp.

• Essential for synchronization for most computer related processes.

• For example, modify timestamps on files requiring backups are essential so that the backup be only taken for files changed or referenced.

• Timestamps recorded automatically by the operating system are file creation and file modification.

• The problem with timestamp is when synchronizing event or message across two devices.