Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 293 - 296 of 354

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

Question 293

C & C Plus Plus
Edit

Describe in Detail

Essay▾
  1. #include<studio.h>
  2. #definea10
  3. main()
  4. {
  5.     #definea50
  6.     printf( “%d” a);
  7. }

Explanation

In a program

Table Shows the Program
#define a 10Define the preprocessor directives a value is 10
main ()

{

#define a 50

Here, define a value also 50.
printf ( “% d” a) ;Print a value is 50

Because, The preprocessor directives can be redefined anywhere in the program

So the most recently assigned value will be taken

Question 294

C & C Plus Plus
Edit

Write in Short

Short Answer▾

Is the following statement a declaration/definition. Find what does it mean?

int (⚹ x) [10] ;

Explanation

  • Here x is a pointer to array of (size 10) integers.
  • Apply clock-wise rule to find the meaning of this definition.

Question 295

C & C Plus Plus
Edit

Write in Short

Short Answer▾

Does C ++ support multilevel and multiple inheritances?

Explanation

  • Yes, C ++ does support multilevel and multiple inheritances.
  • In C ++ we can derive a class D from two base classes A and B- multiple inheritance.
  • Similarly, in C ++ we can also derive class A from B which in turn is derived from class C.

Question 296

C & C Plus Plus
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

Developed by: