GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Placement Papers  >  Birlasoft  >  Technical
Go To First  |  Previous Question  |  Next Question 
 Technical  |  Question 15 of 25    Print  
Which one of the following statements allocates enough space to hold an array of 10 integers that are initialized to 0 ?
a) int *ptr = (int *) calloc(10,sizeof(int));
b) int *ptr = (int *) alloc( 10*sizeof(int));
c) int *ptr = (int *) malloc( 10*sizeof(int));
d) int *ptr = (int *)calloc(10*sizeof(int));

Answered by Ragini rani on 2005-05-13 09:01:56: a is the correct ans Calloc allocates space and initialized them to 0



  
Total Answers and Comments: 9 Last Update: November 08, 2006   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
March 23, 2005 23:18:32   #1  
surya        

RE: Which one of the following statements allocates enough space to hold an array of 10 integers that ...
C is the correct answer. Malloc allocates enough space for 10 integers
 
Is this answer useful? Yes | No
May 13, 2005 09:01:56   #2  
Ragini rani        

RE: Which one of the following statements allocates enough space to hold an array of 10 integers that ...
a is the correct ans Calloc allocates space and initialized them to 0
 
Is this answer useful? Yes | No
July 27, 2005 15:56:48   #3  
vipin dhaiya        

RE: Which one of the following statements allocates enough space to hold an array of 10 integers that ...
ans a is correct because calloc function ll initialize the array to zero
 
Is this answer useful? Yes | No
July 30, 2005 09:34:05   #4  
gaurav dutta        

RE: Which one of the following statements allocates enough space to hold an array of 10 integers that ...
a is the answer
 
Is this answer useful? Yes | No
August 23, 2005 10:58:50   #5  
sandeep paliwal        

RE: Which one of the following statements allocates enough space to hold an array of 10 integers that ...
(a) is the correct answer because calloc initialize the array to zero.....and since 2 arguments are needed for calling calloc function option (d) is incorrect
 
Is this answer useful? Yes | No
May 02, 2006 10:08:19   #6  
sameer_gupta Member Since: May 2006   Contribution: 1    

RE: Which one of the following statements allocates en...
a is the answer,as calloc syntax in d is wrong
 
Is this answer useful? Yes | No
July 24, 2006 03:54:34   #7  
yash grotra        

RE: Which one of the following statements allocates en...
a is the correct answer because calloc initilize the array to zero.
 
Is this answer useful? Yes | No
October 03, 2006 08:34:32   #8  
Santh kumar        

RE: Which one of the following statements allocates en...

 Hi all, i'd like clear difference b/w those  2 functions.

There are 2 differences.

First, is in the number of arguments. malloc() takes a single argument(memory required in bytes), while calloc() needs 2 arguments(number of variables to allocate memory, size in bytes of a single variable).

Secondly, malloc() doesnot initialize the memory allocated, while calloc() initializes the allocated memory to ZERO.

The difference b/w malloc and calloc are: 1. malloc() allocates byte of memory where as calloc()allocates block of memory.

malloc(s); returns a pointer for enough storage for an object of s bytes. calloc(n,s); returns a pointer for enough contiguous storage for n objects,each of s bytes. The storage is all initialised to zeros.


 
Is this answer useful? Yes | No
November 08, 2006 10:19:03   #9  
Purvi mehta        

RE: Which one of the following statements allocates en...
Ans:- C
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape