3i Infotech Placement: Sample Questions 281 - 282 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 281

Edit

Describe in Detail

Essay▾

What do you mean by multithreading?

Explanation

  • A type of execution model that allows multiple threads to exist within a process- they execute independently but share process resources.
  • Thread maintains information relevant to its execution (context) including priority schedule, exception handlers, set of CPU registers, and stack state in the address space of its hosting process.
  • Mostly used in game, animation etc.

Advantages:

  • Threads share memory area (saving memory) and context-switching between the threads takes less time than switching process.
  • Threads do not block the user- they are independent and allow multiple operations at same time.
  • Independent- do not affect other threads if exception occurs.

Question 282

Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. main()
  2. {
  3.     charstr1[] ={‘s’,’o’,’m’,’e’};
  4.     charstr2[] ={‘s’,’o’,’m’,’e’,’⧵0’};
  5.     while (strcmp(str1,str2)) printf(“Stringsarenotequal”);
  6. }

Explanation

In the program

Table Shows the Program
char str1 [] = { ‘s’ , ‘o’ , ‘m’ , ‘e’ } ; char str2 [] = { ‘s’ , ‘o’ , ‘m’ , ‘e’ , ‘⧵0’ } ;
  • Given the two character arrays str1 and str2.
  • If a string constant is initialized explicitly with characters, ‘⧵0’ is not appended automatically to the string.
while (strcmp (str1, str2) )
  • Strcmp compares the str1 and str2
  • Since str1 doesn՚t have null termination
  • It treats whatever the values that are in the following positions as part of the string until it randomly reaches a ‘⧵0’ .
printf ( “Strings are not equal” ) ;
  • str1 and str2 are not the same
  • So, printf prints Strings are not equal

Developed by: