3i Infotech Placement: Sample Questions 1067 - 1068 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 1067

Edit

Describe in Detail

Essay▾

How would you use bsearch () function to search a name stored in array of pointers to string?

Explanation

Understanding of Binary Search
  • bsearch is a library function which is used to do binary search of the array sorted in ascending order.
  • For using this function program has to include stdlib. h library function.

Syntax

void ⚹ bsearch (void ⚹ target, void ⚹ table, size num, size width, int (⚹ cmpfp) (void ⚹ emt1, void ⚹ emt2) ) ;

Where,

target: A pointer to the element we are searching.

table: The array we are searching.

num: The size of the array

width: The size of each array element.

cmpfp: A pointer to a function to compare the target and an element in the array

Question 1068

Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. voidmain ()
  2. {
  3.     printf (“sizeof(void ⚹) =%d”, sizeof (void ⚹) );
  4.     printf (“sizeof(int ⚹) =%d”, sizeof (int ⚹) );
  5.     printf (“sizeof(double ⚹) =%d”, sizeof (double ⚹) );
  6.     printf (“sizeof(structunknown ⚹) =%d”, sizeof (structunknown ⚹) );
  7. }

Explanation

Sizeof (void ⚹) = 2sizeof (int ⚹) = 2sizeof (double ⚹) = 2sizeof (struct unknown ⚹) = 2

  • In the program
Table Shows the Program
printf ( “sizeof (void ⚹) =% d” , sizeof (void ⚹) ) ;
  • The pointer to void type is size of 2
printf ( “sizeof (int ⚹) =% d” , sizeof (int ⚹) ) ;
  • The pointer to integer type is size of 2
printf ( “sizeof (double ⚹) =% d” , sizeof (double ⚹) ) ;
  • The pointer to double type is size of 2
printf ( “sizeof (struct unknown ⚹) =% d” , sizeof (struct unknown ⚹) ) ;
  • The pointer to struct unknown type is size of 2
  • The pointer to any type is of same size.

Developed by: