LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C Programming
  • Memory Allocation

C Programming

MEMORY ALLOCATION MCQs

Total Questions : 10

Question 1.

When we dynamically allocate memory is there any way to free memory during run time?


  1.    Yes
  2.    No
 Discuss Question
Answer is Option A. -> Yes

Using free()
Question 2.

Can I increase the size of statically allocated array?


  1.    Yes
  2.    No
 Discuss Question
Answer is Option B. -> No

Question 3.

Can I increase the size of dynamically allocated array?


  1.    Yes
  2.    No
 Discuss Question
Answer is Option A. -> Yes

Use realloc(variable_name, value);
Question 4.

If malloc() successfully allocates memory it returns the number of bytes it has allocated.


  1.    True
  2.    False
 Discuss Question
Answer is Option B. -> False

Syntax: void *malloc(size_t size);

The malloc() function shall allocate unused space for an object whose size in bytes is specified by size and whose value is unspecified.

The order and contiguity of storage allocated by successive calls to malloc() is unspecified. 
Question 5.

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.


  1.    True
  2.    False
 Discuss Question
Answer is Option B. -> False

Question 6.

malloc() allocates memory from the heap and not from the stack.


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

Question 7.

malloc() returns a NULL if it fails to allocate the requested memory.


  1.    True
  2.    False
 Discuss Question
Answer is Option A. -> True

Question 8.

Which of the following statement is correct prototype of the malloc() function in c ?


  1.    int* malloc(int);
  2.    char* malloc(char);
  3.    unsigned int* malloc(unsigned int);
  4.    void* malloc(size_t);
 Discuss Question
Answer is Option D. -> void* malloc(size_t);

Question 9.


Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program?



#include<stdio.h>
#include<stdlib.h>

iint main()
{
struct ex
{
int i;
float j;
char *s
};
struct ex *p;
p = (struct ex *)malloc(sizeof(struct ex));
p->s = (char*)malloc(20);
return 0;
}

  1.    free(p); , free(p->s);
  2.    free(p->s); , free(p);
  3.    free(p->s);
  4.    free(p);
 Discuss Question
Answer is Option B. -> free(p->s); , free(p);

Question 10.


Point out the correct statement which correctly allocates memory dynamically for 2D array following program?



#include<stdio.h>
#include<stdlib.h>

int main()
{
int *p, i, j;
/* Add statement here */
for(i=0; i
  1.    p = (int*) malloc(3, 4);
  2.    p = (int*) malloc(3*sizeof(int));
  3.    p = malloc(3*4*sizeof(int));
  4.    p = (int*) malloc(3*4*sizeof(int));
 Discuss Question
Answer is Option D. -> p = (int*) malloc(3*4*sizeof(int));

  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Arrays
  • Bitwise Operators
  • C Preprocessor
  • Command Line Arguments
  • Complicated Declarations
  • Const
  • Control Instructions
  • Declarations And Initializations
  • Expressions
  • Floating Point Issues
  • Functions
  • Input / Output
  • Library Functions
  • Memory Allocation
  • Pointers
  • Strings
  • Structures
  • Subleties Of Typedef
  • Variable Number Of Arguments

Topics

  • Computer Aptitude
  • SAIL Junior Officer (E-0)
  • 10th Grade
  • 11th Grade
  • 12th Grade
  • 4th Grade
  • 5th Grade
  • 6th Grade
  • 7th Grade
  • 8th Grade
  • 9th Grade
  • NCERT
  • Cat
  • Commerce
  • Computer Science
  • Engineering
  • English
  • General Knowledge
  • Ias
  • Management
  • Quantitative Aptitude
  • Reasoning Aptitude
  • General Studies (Finance And Economics)
  • Analytical Instrumentation
  • Biochemistry
  • Bioinformatics
  • Biology
  • Biotechnology
  • Bitsat
  • Business Statistics
  • C Programming
  • C++ Programming
  • Cell Biology
  • Chemistry
  • Cost Accounting
  • Drug And Pharmaceutical Biotechnology
  • Electrical Measurement And Instrumentation
  • Environment Management
  • Environmental Biotechnology
  • Enzyme Technology
  • Financial Management And Financial Markets
  • Gate
  • General Science
  • Geography
  • Heat Transfer
  • History And National Movements
  • Human Anatomy And Physiology
  • Human And Cultural Diversity
  • Human Resource Management
  • Indian Economy
  • Indian Geography
  • Indian History
  • Indian Polity
  • Instrumentation Transducers
  • International Relations
  • Life Sciences
  • Marketing And Marketing Management
  • Mass Transfer
  • Mechanics Of Materials
  • Microbiology
  • Neet
  • Professional Communication
  • Renewable Energy
  • Sociology
  • Surveying
  • Total Quality Management
  • Uidai Aadhaar Supervisor Certification
  • Virology

Recent Questions

Q.   What Are The Intrinsic Factors For The Microbial Growth?

Q.   ....

Q.   If V₁ Is The Jet Velocity And V₀ Is The Vehicle Velocity....

Q.   ....

Q.   Addition Of Tungsten To Steel Imparts

Q.   Three Friends Had Dinner At A Restaurant. When The Bill Was ....

Q.    25 Pieces Of Shirt Each 125 Cm In Length Can Be Cut Fror A....

Q.   ....

Q.   Find Out That Word, The Spelling Of Which Is Wrong.

Q.   Laser Jet Printer Speeds Are Measured In Pages Per Minute (p....

Q.   A Bag Contains 25 Kg Of Rice At ₹ 20.04 Per Kg And 20....

Q.   Regarding The Assertion And Reason, Choose The Correct Optio....

Q.   The Increase In Entropy Of A System Represents

Q.   The SI Unit Of ___ Is Named After Andre Marie Ampere.

Q.   The Predominent Isotope Of The Naturally Occuring Element I....

Q.   Gravity Feed Method For Solvent Delivery Is Not Used With Na....

Q.   Vanita Bought A Watch With 25% Discount On The Selling Price....

Q.    if A Boat Goes 7 Km Upstream In 42 Minutes And The Speed O....

Q.   Scavenging Air In Diesel Engine Means

Q.   The Prices Of Bonds Will Be Increased If The Interest Rates

LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • YouTube Channel
  • Maths Fast Trick
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password