Languages [3i Infotech Placement]: Sample Questions 542 - 543 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 542

Edit

Write in Short

Short Answer▾

What is NULL Micro? What is the difference between a NULL pointer and a NULL Macro?

Explanation

  • Macro is used for defining a constant value to a constant reference.
  • Null macro is defining 0 to NULL.

Bellow it is defined:

#define NULL 0;

Difference between a NULL Pointer and a NULL Macro
NULL pointerNULL macro
A pointer which has 0 or NULL value points to points to memory location Defined in stdio. h and stddef. h.
Not be confused with an uninitialized pointer.Is used to represent a null pointer in code.

Question 543

Edit

Describe in Detail

Essay▾

Find the output of the following program

  1. Voidmain()
  2. {
  3.     inta, ⚹pa, &ra;
  4.     pa =&a; ra =a; cout ≪"a=”;
  5. }

Explanation

  • In the program
Table Showing the Program
int a, ⚹ pa, &ra;
  • Define the integer variable a , pointer pa and reference of ra
pa = &a;
  • Pointer ‘pa’ assigned the address of ‘a’
ra = a;
  • Reference ‘ra’ assigned the address of ‘a’
cout << “a = ” ;
  • Prints the value of a
  • Here pointers are different from references.
  • One of the main differences is that the pointers can be both initialized and assigned, whereas references can only be initialized.
  • Compiler Error: ‘ra’ reference must be initialized
  • So, this code issues an error.

Developed by: