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

C & C Plus Plus
Edit

Write in Short

Short Answer▾
  1. voidmain ()
  2. {
  3.     intconst ⚹p =5;
  4.     printf (“%d” ++ (⚹p));
  5. }

Explanation

  • In a program
Table Shows the Program
int const ⚹ p = 5;Pointer to constant integer
printf ( “% d” ++ (⚹ p) ) ;We tried to change constant integer value
  • But constant value can՚t change
  • So, the answer is Compiler error: Cannot modify a constant value.

Question 100

C & C Plus Plus
Edit

Write in Short

Short Answer▾

When will a constructor executed

Explanation

  • Inbuilt or default constructor, no parameter constructor are executes when objects are created.
  • Parameterized constructor execute whenever it is called.

Question 101

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. # include <stdio.h>
  2. intone_d[] ={ 1, 2, 3};
  3. main ()
  4. {
  5.     int ⚹ptr;
  6.     ptr =one_d;
  7.     ptr += 3;
  8.     printf ( “%d” ⚹ptr);
  9. }

Explanation

In the program

Table Shows the Program
int one_d [] = {1,2, 3} ;Define global integer array one_d = {1,2, 3}
int ⚹ ptr;Define the integer pointer ptr.
ptr = one_d;Ptr pointer is pointing “out of range” of array one_d
printf ( “% d” ⚹ ptr) ;So, printf prints garbage value

So, answer will be garbage value

Question 102

C & C Plus Plus
Edit

Write in Short

Short Answer▾

When is a memory allocated to a class?

Explanation

Unsderstanding of Allocated to a Class
  • Memory is allocated when instance of a class is created.
  • A class is a template- allocated memory when object of that class is created.

Developed by: