adplus-dvertising

Welcome to the Library Functions MCQs Page

Dive deep into the fascinating world of Library Functions with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Library Functions, a crucial aspect of C Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Library Functions, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Library Functions. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Library Functions. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Library Functions MCQs | Page 11 of 13

Q101.
What is the output of this program?
#include <stdio.h>
#include  <stdlib.h>
int main()
{
  int i, numbers[1];
  numbers[0] = 15;
  free(numbers);
  printf("Stored integers are ");
  printf("numbers[%d] = %d ", 0, numbers[0]);
  return 0;
}
Discuss
Answer: (a).15
Q102.
What is the output of this program?
#include <stdio.h>
#include  <stdlib.h>
int main()
{
   int *j = (int*)malloc(4 * sizeof(int));
   *j = 15;
   free(j);
   printf("%d", *j);
   return 0;
}
Discuss
Answer: (b).Some Garbage value
Q103.
What is the output of this program?
#include <stdio.h>
#include  <stdlib.h>
int main()
{
   int *numbers = (int*)calloc(4, sizeof(int));
   numbers[0] = 2;
   free(numbers);
   printf("Stored integers are ");
   printf("numbers[%d] = %d ", 0, numbers[0]);
   return 0;
}
Discuss
Answer: (c).0
Q104.
What is the output of this program?
#include <stdio.h>
void main()
{
   int *ptr = (int *)malloc(sizeof(int));
   *ptr = 10;
   free(ptr);
   p = 5;
   printf("%d", ptr);
}
Discuss
Answer: (b).5
Q105.
What is the output of this program?

#include <stdio.h>
#include  <stdlib.h>
int main()
{
  int i;
  char *ptr;
  char *fun();
  ptr = fun();
  printf(" %s", ptr);
  return 0;
}

char *fun()
{
  char disk[30];
  strcpy(disk, "compsciedu");
  printf("%s ",disk);
  return disk;
}
Discuss
Answer: (a).compsciedu
Q106.
What is the output of this program?
#include <stdio.h>
#include  <stdlib.h>
int main()
{
  int *p;
  p = (int *)malloc(40);
  printf("%d", sizeof(p));
  free(p);
  return 0;
}
Discuss
Answer: (c).30
Q107.
What is the output of this program?
#include <stdio.h>
#include  <stdlib.h>
int main()
{
  struct test
  {
    int i;
    float f;
    char c;
  };
  struct test *ptr;
  ptr = (struct test *)malloc(sizeof(struct test));
  ptr ->f = 2.5f;
  printf("%f", ptr->f);
  return 0;
}
Discuss
Answer: (b).2.5
Q108.
Which statment is true about the given code ?
#include <stdio.h>
#include  <stdlib.h>
int main()
{
    int *a[5];
    a = (int*) malloc(sizeof(int)*5);
    free(a);
    return 0;
}
Discuss
Answer: (b).Error: We cannot store address of allocated memory in a
Q109.
What is the Error of this program?
#include <stdio.h>
#include  <stdlib.h>
int main()

{
     char *ptr;
     *ptr = (char)malloc(30);
     strcpy(ptr, "RAM");
     printf("%s", ptr);
     free(ptr);
     return 0;
}
Discuss
Answer: (b).Error: in *ptr = (char)malloc(30);
Q110.
How will you free the memory allocated by the following program?
#include <stdio.h>
#include  <stdlib.h>
#define MAXROW 2
#define MAXCOL 3
int main()
{
    int **p, i, j;
    p = (int **) malloc(MAXROW * sizeof(int*));
    return 0;
}
Discuss
Answer: (d).free(p);

Suggested Topics

Are you eager to expand your knowledge beyond C Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!