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

Edit

Describe in Detail

Essay▾

Difference between malloc () & calloc () memory allocation.

Explanation

Difference between Malloc () & Calloc () Memory
malloc ()calloc ()
  • The name malloc stands for memory allocation.
  • The name calloc stands for contiguous allocation.
  • malloc () takes one argument that is, number of bytes.
  • calloc () take two arguments those are: number of blocks and size of each block.
  • syntax of malloc () :

    void ⚹ malloc (size_t n) ;

  • syntax of calloc () :
void ⚹ calloc (size_t n, size_t size) ;
  • Byte of memory is allocated
  • Block of memory is allocated
  • Memory initialization is not performed
  • Memory is initialized
  • Return a pointer with enough storage with s bytes.
  • Returns a pointer with enough storage each with s bytes.

Question 149

Edit

Describe in Detail

Essay▾
  1. main ()
  2. {
  3.     externout;
  4.     printf ( “%d” out);
  5. }
  6. intout =100;

Explanation

  • In a program using external linkage
  • This means that the object or function is accessible through this name from other translation units in the program
    Table Showing the Program
    extern out;Here out is external object.
    printf ( “% d” out) ;Print the value of out
    int out = 100;Here out is external object integer and it՚s value is 100
  • So the answer is 100.

Developed by: