C Programming > Memory Allocation

C Programming Questions and Answers

C Programming > Memory Allocation

Postby abdulsaboor » Thu Oct 02, 2014 11:35 am

C Programming > Memory Allocation

1.
Which header file should be included to use functions like malloc() and calloc()?

A. memory.h
B. stdlib.h
C. string.h
D. dos.h

Answer: Option B

2.
What function should be used to free the memory allocated by calloc() ?

A. dealloc();
B. malloc(variable_name, 0)
C. free();
D. memalloc(variable_name, 0)

Answer: Option C
DR ABDUL SABOOR
PHD Scholar at Superior University Lahore- Pakistan
MS Business Administration (HRM)
BS Business Administration (Marketing)
Member Editorial Board Science Publishing Group USA
Member Editorial Board International Journal of Marketing Studies
Cell=0308-6837987

Pakistan
User avatar
abdulsaboor
ADMIN
ADMIN
 
Posts: 2004
Joined: Fri Sep 28, 2007 3:42 am
Location: vehari-punjab-pakistan

Re: C Programming > Memory Allocation

Postby abdulsaboor » Thu Oct 02, 2014 11:36 am

3.
How will you free the memory allocated by the following program?

#include<stdio.h>
#include<stdlib.h>
#define MAXROW 3
#define MAXCOL 4

int main()
{
int **p, i, j;
p = (int **) malloc(MAXROW * sizeof(int*));
return 0;
}

A. memfree(int p);
B. dealloc(p);
C. malloc(p, 0);
D. free(p);

Answer: Option D
DR ABDUL SABOOR
PHD Scholar at Superior University Lahore- Pakistan
MS Business Administration (HRM)
BS Business Administration (Marketing)
Member Editorial Board Science Publishing Group USA
Member Editorial Board International Journal of Marketing Studies
Cell=0308-6837987

Pakistan
User avatar
abdulsaboor
ADMIN
ADMIN
 
Posts: 2004
Joined: Fri Sep 28, 2007 3:42 am
Location: vehari-punjab-pakistan

Re: C Programming > Memory Allocation

Postby abdulsaboor » Thu Oct 02, 2014 11:37 am

4.
Specify the 2 library functions to dynamically allocate memory?

A. malloc() and memalloc()
B. alloc() and memalloc()
C. malloc() and calloc()
D. memalloc() and faralloc()

Answer: Option C
DR ABDUL SABOOR
PHD Scholar at Superior University Lahore- Pakistan
MS Business Administration (HRM)
BS Business Administration (Marketing)
Member Editorial Board Science Publishing Group USA
Member Editorial Board International Journal of Marketing Studies
Cell=0308-6837987

Pakistan
User avatar
abdulsaboor
ADMIN
ADMIN
 
Posts: 2004
Joined: Fri Sep 28, 2007 3:42 am
Location: vehari-punjab-pakistan


Return to C Programming

Who is online

Users browsing this forum: No registered users and 2 guests
cron