3i Infotech Papers: Sample Questions 121 - 124 of 1245

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

Question number: 121

» Operating System » Unix

Essay Question▾

Describe in Detail

What are states that the page can be in, after causing a page fault?

Explanation

Define page fault issues

Define Page Fault Issues

Define page fault issues

  • On a swap device and not in memory.

  • On the free page list in the main memory.

  • In an executable file.

  • Marked “demand zero”.

  • Marked “demand fill”.

Question number: 122

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What is the output of the following?

  1. int ii=1i=i+2*i++; printf(“%d”,i);

Explanation

  • In the program

Table showing the program

Table showing the program

int i;

  • define the integer variable i

i = 1;

  • Here integer variable i is assigned the value of 1

i = i+2 * i++;

  • here i = i+2 * i++;

i = 1+2 * 1++

i = 3*1++

i = 3++

i = 4

printf (“%d”, i);

  • printf prints the value of i is 4

Question number: 123

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

  1. #define one 0
  2. #ifdef one
  3. printf ( “one is defined” );
  4. #endif
  5. #ifndef one
  6. printf ( “one is not defined” );
  7. #endif

Explanation

  • In the program ifdef means “if the following is defined” while ifndef means “if the following is not defined”.

Table showing the program

Table showing the program

#define one 0

  • Here one is defined

#ifdef one

printf (“one is defined”);

#endif

  • Check the one is defined or not.

  • Since one is defined so the ifdef is true and the ifndef is false.

  • So printf prints “one is defined”.

Question number: 124

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

What is output for the following program?

  1. #include
  2. main ()
  3. {
  4.     unsigned char c[] = { 0 × 10 × 20 × 30 × 40 × 110 × 220 × 330 × 44};
  5.     unsigned int * p = c;
  6.     unsigned short * s = c;
  7.     printf ( “%x %x %x” c[2], p[2], s[2]);
  8. }

Explanation

Table showing the program

Table showing the program

#include

Standard library function

main ()

startup after initialization

unsigned char c [] = [1,2, 3,4, 5,6, 7,8, 9,10,11,12,13];

Declare unsigned char [8],

unsigned int * p = c;

Declare unsigned integer pointer to character p which points to beginning of array c [].

unsigned short * s = c;

Declare unsigned short pointer s which also points to beginning of c

printf (“%x % x %x” c [2], p [2], s [2] );

  • Note that s is pointer of short which is 2 bytes, int is 4 bytes, char is 1 byte.

  • c [2] will get the third element which is 3

  • p [2] will get to bytes location in the array which is 13

  • s [2] will get to byte location in the array which is 7.

Table showing the program

Table showing the program

Type

Storage size

Value range

char

1 byte

-128 to 127 or 0 to 255

unsigned char

1 byte

0 to 255

signed char

1 byte

-128 to 127

int

2 or 4 bytes

-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647

unsigned int

2 or 4 bytes

0 to 65,535 or 0 to 4,294,967,295

short

2 bytes

-32,768 to 32,767

unsigned short

2 bytes

0 to 65,535

long

4 bytes

-2,147,483,648 to 2,147,483,647

unsigned long

4 bytes

0 to 4,294,967,295