3i Infotech Placement: Sample Questions 299 - 300 of 1245

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

Question 299

Describe in Detail Essay▾

Predict the output or error (s) for the following:

  1. main ()
  2. {
  3. int i =300;
  4. char ptr=&i;
  5. ⚹++ptr=2;
  6. printf ( “%d”,i);
  7. }
Edit

Explanation

In the program

Table Shows the Program
int i = 300;
  • Given the integer variable i = 300
char ⚹ ptr = &i;
  • The integer value 300 in binary notation is: 00000001 00101100.
  • It is stored in memory (small-endian) as: 00101100 00000001.
⚹+ + ptr = 2;
  • Result of the expression ⚹+ + ptr = 2 makes the memory representation as: 00101100 00000010.
printf ( “% d” , i) ;
  • So the integer corresponding to it is 00000010 00101100 ⩾ 556.
Convert Binary Value to Integer Value

Question 300

Describe in Detail Essay▾

What is fork command in UNIX?

Edit

Explanation

  • Form system call creates a new process- child process, which runs concurrently with the current process and the current process is called parent process.
  • After a new child process is created, both processes execute the next instruction following the fork () system call.
  • Child process uses the same CPU registers open files used by parent process.
  • It take no parameters and returns integer value
  • Form copies the parent՚s page tables for child using copy-on-write pages.
  • Only penalty incurred is time and memory to duplicate the parent՚s page tables, and to create a unique task structure for the child.