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

C & C Plus Plus
Edit

Describe in Detail

Essay▾

How do you declare the following:

Explanation

  • An array of three pointers to chars.
    • char ⚹ p [3] ;
    • An array of three char pointers.
    • char ⚹ p [3] ;
    • A pointer to array of three chars.
    • char (⚹ ptr) [3] ;
    • A pointer to function which receives an int pointer and returns a float pointer.
    • float ⚹ (⚹ ptr) (int ⚹) ;
    • A pointer to a function which receives nothing and returns nothing.
  • void (⚹ ptr) () ;

Question 276

C & C Plus Plus
Edit

Describe in Detail

Essay▾
  1. #include<studio.h>
  2. main ()
  3. {
  4.     structxx
  5.     {
  6.         intx =3;
  7.         charname[] =“hello
  8.     };
  9.     structxx ⚹s;
  10.     printf ( “%d” s ⇾ x);
  11.     printf ( “%s” s ⇾ name);
  12. }

Explanation

  • In C language all variables declare in first and then apply and function.
  • But here should not initialize variables in declaration.
Table Shows the Program
  1. structxx
  2. {
  3.     intx =3;
  4.     charname[] =“hello
  5. };
Here struct xx is a declaration

Define integer variable x = 3

And char array name [] = “hello”

struct xx ⚹ s;Struct xx define a pointer s
printf ( “% d” s ⇾ x) ;Here print the value of x but x not initialize variable in declaration
  • So the Answer is Compiler Error.

Question 277

C & C Plus Plus
Edit

Write in Short

Short Answer▾

What is dangling pointer?

Explanation

  • Dangling pointer arises on using the address of an object after its lifetime is over.
  • This occurs in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.
  • Dangling pointers arise during object destruction, when an object that has an incoming reference is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory.
Define the Dangling Pointers Exploitation

Developed by: