3i Infotech Placement: Sample Questions 834 - 835 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 834

Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. main ()
  2. {
  3.     inta =2, ⚹f1, ⚹f2;
  4.     f1 =f2 =&a;
  5.     f2 += ⚹f2 += a += 2.5;
  6.     printf ( “ %d %d %d”, a, ⚹f1, ⚹f2);
  7. }

Explanation

In the program

Table Shows the Program
int a = 2, ⚹ f1, ⚹ f2;
  • Given the integer variable a = 2 and pointer variable f1 and f2.
f1 = f2 = &a;
  • f1 and f2 both refer to the same memory location a.
⚹ f2 += ⚹ f2 += a += 2.5;⚹ f2 =⚹ f2 + (⚹ f =⚹ f2 + (a = a + 2.5) )

a = a + 2.5 = 4

so ⚹ f2 = 4

⚹ f2 =⚹ f2 + 4 = 8

Now ⚹ f2 = 8

So, ⚹ f2 =⚹ f2 + 8 = 16

printf ( “% d % d % d” , a, ⚹ f1, ⚹ f2) ;So changes through f1 and f2 ultimately affects only the value of a.

So the answer is 16 16 16

Question 835

Edit

Describe in Detail

Essay▾

A thread is

Explanation

Understanding of Thread Process in Image
  • A thread is a flow of control through a program with a single execution point.
  • There can be several threads of execution within a process.
  • A heavyweight process has a single thread of control.
  • Multitasking allows many processes to run concurrently, while multithreading allows many sub-processes to run concurrently.
  • The thread allows a program to be re-entered on behalf of different users.
  • Multithreading is also used extensively in computer-generated animation.

Developed by: