ExamVeda
Login
Home
41
The following C code is an example of . . . . . . . .
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{
    char *p,*q;
    p=(char*)malloc(3*sizeof(char));
    q=p;
    strcpy(p,"hello");
    printf("p=%s",p);
    printf("q=%s",q);
    free(q);
    q=NULL;
    gets(p);
    gets(q);
    printf("%s",p);
    printf(“%s”,q);
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
42
If malloc() and calloc() are not type casted, the default return type is . . . . . . . .
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
43
Which of the following functions allocates multiple blocks of memory, each block of the same size?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
44
A condition where in memory is reserved dynamically but not accessible to any of the programs is called . . . . . . . .
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
45
Which of the following header files must necessarily be included to use dynamic memory allocation functions?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
46
What will be the error (if any) in the following C code?
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    char *p;
    *p = (char)calloc(10);
    strcpy(p, "HELLO");
    printf("%s", p);
    free(p);
    return 0;
}
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
47
What will happens if the statement free(a) is removed in the following C code?
#include<stdio.h>
#include<stdlib.h>
main()
{
    int *a;
    a=(int*)malloc(sizeof(int));
    *a=100;
    printf("*a%d",*a);
    free(a);
    a=(int*)malloc(sizeof(int));
    *a=200;
    printf("a%p",a);
    *a=200;
    printf("a%d",*a);
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
48
In the function realloc(), if the new size of the memory block is larger than the old size, then the added memory . . . . . . . .
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
49
What will be the output of the following C code if it is executed on a 32 bit processor?
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int *p;
    p = (int *)malloc(20);
    printf("%d\n", sizeof(p));
    free(p);
    return 0;
}
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
50
Garbage collector frees the programmer from worrying about . . . . . . . .
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board