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

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What does error ‘NULL pointer assignment’ mean and what causes this error?

Explanation

  • NULL pointer error happens when the program tries to store value in the location pointed to by the NULL pointer.
  • A null pointer assignment is a runtime error.

Question 6

C & C Plus Plus
Edit

Write in Short

Short Answer▾
  1. main ()
  2. {
  3.     printf( “%p” main);
  4. }

Explanation

  • In a program
Table Shows the Program
  1. main ()
  2. {
  3.     printf( “%p” main);
  4. }
Function names are just addresses (just like array names are addresses) .

Here, main () is also a function.

So, the address of function main will be printed.

  • % p in printf specifies that the argument is an address.
  • They are printed as hexadecimal numbers.
  • Some address will be printed

Question 7

C & C Plus Plus
Edit

Write in Short

Short Answer▾

How is structure passing and returning implemented by the compiler?

Explanation

  • When structure is passed as argument to functions, the entire structure is pushed on the stack, using as much memory as required.
  • Some compilers merely pass a pointer to the structure, though they may have to make a local copy to preserve pass-by-value semantics.
  • Structures are often returned from functions in a location pointed to by an extra, compiler-supplied “hidden” argument to the function.
  • Compilers used a special, static location for structure returns, although this makes structure-valued functions non-re-entrant, which ANSI C disallows.

Developed by: