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

Describe in Detail Essay▾

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

Edit

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. typedef struct emp_list
  4. {
  5. int id;
  6. char name[10];
  7. }
  8. EMP;
  9. int sorting_mech( const void ele1 , const void ele2)
  10. {
  11. int a,b;
  12. a =⚹((int ⚹)ele1);
  13. b =⚹((int ⚹)ele2);
  14. if( a >b)
  15. {
  16. return 1;
  17. }
  18. if(a <b )
  19. {
  20. return -1;
  21. }
  22. return 0;
  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

Write in Short Short Answer▾

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

Edit

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.