Languages [3i Infotech Placement]: Sample Questions 505 - 506 of 546

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

Question 505

Edit

Describe in Detail

Essay▾

How would you use qsort () function to sort an array of structures?

Explanation

  • qsort () is an standard C library function, for sorting an array.
  • It uses two argument one of which contains logic to decide order in sorted output.
  • This provides flexibility so qsort () to use many types and can be used to obtain any desired order.
  • The compare function takes two pointers as arguments and defines the order.
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. typedefstructemp_list
  4. {
  5.     intid;
  6.     charname[10];
  7. }
  8. EMP;
  9. intsorting_mech( constvoid ⚹ele1 , constvoid ⚹ele2)
  10. {
  11.     inta,b;
  12.     a =⚹((int ⚹)ele1);
  13.     b =⚹((int ⚹)ele2);
  14.     if( a >b)
  15.     {
  16.         return1;
  17.     }
  18.     if(a <b )
  19.     {
  20.         return -1;
  21.     }
  22.     return0;
  23. }
  24. qsort(&emp_list_array, &sorting_mech);

The function sorting_mech will be called by the qsort to sort order employees whenever there is need.

Question 506

Languages
Edit

Write in Short

Short Answer▾

What is meant by distributed application? Why are we using that in our application?

Explanation

Understanding of Distributed Operating System
  • Distribution application is executed or run on multiple computers within a network.
  • Such applications interact (over network) to achieve a specific goal or task.
    • They can use client-server model where application software runs as either client, or the server that the client accesses.
    • Front end on the client computer requires minimal processing power.

Developed by: