Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following 3 code fragments: 1) int *ptr = malloc (sizeof(int)*3); ptr[0] = 0; ptr[1] 0; ptr[2] 0; 2) int ptr - calloc

image text in transcribed
image text in transcribed
Consider the following 3 code fragments: 1) int *ptr = malloc (sizeof(int)*3); ptr[0] = 0; ptr[1] 0; ptr[2] " 0; 2) int ptr - calloc (3, sizeof (int)) if (ptr== NULL){ printf ("Unable to allocate memory. In") exit (1): 3) int iptr= calloc ( 1 , sizeof (int)); if (ptr-NULL) { printf("Unable to allocate memory.In") exit (1) ptr realloc (ptr, 3 sizeof (int)) if (ptrNULL) printf("Unable to allocate memory.In") exit (1) Dynamic allocation of an integer array of size 3 with elements initialized to O is safely done in code fragment(s)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions