Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 22 - 24 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 22

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is the use of ‘using’ declaration.

Explanation

  • A using declaration makes it possible to use a name from a namespace without the scope operator.
  • Using declaration can be used to introduce namespace members into other namespaces and block scopes, or to introduce base class members into derived class definitions.
Define the Using Declaration for a Class Member Shall be a Member Declaration

Question 23

C & C Plus Plus
Edit

Describe in Detail

Essay▾
  1. #definef (g, g2) g##g2
  2. main ()
  3. {
  4.     intvar12 =100;
  5.     printf ( “%d” f (var, 12) );
  6. }

Explanation

  • In a program,
    Table Showing the Program
    #define f (g, g2) g##g2The ## is a concatenation operator,

    When you pass the two arguments they get concatenated asi/p ⇾ f (g, g2) g##g2o/p ⇾ gg2

    int var12 = 100;Define the integer variable var12 = 100
    printf ( “% d” f (var, 12) ) ;hencef (var, 12) will give us var12effectively the printf statement gets modified as printf ( “% d” , f (var, 12) ) ; ⇾ printf ( “% d” , var12) ;
  • So, the answer is 100

Question 24

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is the difference between declaration and definition?

Explanation

Difference between Declaration and Definition
DeclarationDefinition
Declaration tells the compiler the type and nature of method.Specifies the functionality of function.
Declaration specified with ‘extern’ will possibly be defined in another module.Specified in ‘module’ the variable is rooted.
Declaration can be a forward declaration.Definition is no longer a forward declaration
Variable exists.Variable itself.

Developed by: