about c and data structures

I don’t understand this C Programming question and need help to study.

QUESTION 1

Given this code:

int a = 100;

int* ptr:

Which of the following expressions can ptr NOT be assigned to?

(int *) malloc( sizeof ( int ) );

(int *) calloc( a, sizeof ( int ) );

&a

a

(int *) malloc( a * sizeof ( int ) )

2

Which of the following prototypes is NOT syntactically correct

in C?

void doMagicGammaTwo ( int, int, char * );

void doMagicGammaTwo ( int length, int size, char *string);

void doMagicGammaTwo ( int, int size, char string();

void doMagicGammaTwo ( int, int, char 0);

void doMagicGammaTwo ( int length, int size, char string(1)

3

If our program no longer has a need for memory that has been dynamically allocated, what should we do with it?

Dynamically allocate it

Add it to a linked list

Add it to the stack

Deallocate it

Set the pointer equal to NULL?

4Searching and Sorting. The following function is an incomplete Insertion Sort function:

void insertionSort( int *array, int length )

{

int i, j, temp;

for( i = 0; i < length; i++)

{

j = i;

while( j >0 && array [ j ] < array[j – 11])

(AAAA]

[BBBB]

}

Which of the following statements describe what is happening in [AAAA] and [BBBB]?

O [AAAA] swaps the values at index j and index j+ 1; and [BBBB] increments j

O [AAAA] swaps the values at index j and indexj+ 1; and (BBBB] decrements j

O (AAAA) swaps the values at index j and index j – 1; and (BBBB) decrements

[AAAA] swaps the values at index jand index j- 1; and (BBBB) increments

O [AAAA] swaps the values at index j and index j- 1; and [BBBB] has nothing

5 given this code

char str[]= “Linux”;

What is the value of str[ 5 ]?

‘n’

Out of bounds – unknown value

‘x’

Out of bounds – segmentation fault

Order this or a similar paper and get 20% discount on your first order with us. Use coupon: GET20