Purpose of using fflush() function −
Answer: A
This function is used to flush output stream only. It clears the output buffer and send the output to the console.
Enter details here
Point out the error of the following code −
#include
#include
#include
int main() {
char* ptr;
*ptr = (int*)malloc(30);
strcpy(ptr, "ABC");
printf("%s", ptr);
free(ptr);
}
Answer: B
Here this makes integer from pointer, without a cast
Enter details here
What is the output of this program?
#include
#include
int main()
{
struct test
{
int i;
float f;
char c;
};
struct test *ptr;
ptr = (struct test *)malloc(sizeof(struct test));
ptr ->f = 5.5f;
printf("%f", ptr->f);
return 0;
}
Answer: C
Here test is a structure name which consist of three variables of three different data types. ptr is the pointer variable, for which the memory is allocated dynamically by using malloc() of function and then it is pointed towards the structure floating variable f. Now f is initialized with a value 5.5f and then outputted as 5.500000.
Enter details here
If malloc() successfully allocates memory it returns the number of bytes it has allocated.
Answer: B
No answer description available for this question.
Enter details here
What will be the output of the program (16-bit platform)?
#include
#include
int main()
{
int *p;
p = (int *)malloc(20);
printf("%d\n", sizeof(p));
free(p);
return 0;
}
Answer: B
No answer description available for this question
Enter details here
On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to?
Answer: C
None
Enter details here
We use malloc and calloc for
Answer: A
No answer description available for this question.
Enter details here
malloc() returns a float pointer if memory is allocated for storing float's and a double pointer if memory is allocated for storing double's. A.
Answer: B
malloc() and calloc() return void pointer for using a particular data type we made explicite type casting.
Enter details here
Which header file should be included to use functions like malloc() and calloc()?
Answer: B
No answer description available for this question
Enter details here