// Using malloc create an array that contains the product of the
each element in *p_first with the
// corresponding element in *p_second and store that sum in the
corresponding element in the
// returned array of integers.
// e.g. p_result[0] = p_first[0] * p_second[0]; p_result[1] =
p_first[1] * p_second[1]
// Note -- this array must be the same size as the passed in
arrays.
// Note that you can assume that the p_first and p_second arrays
are the same size.
// The third parameter is the number of entries in each
array.
// Return NULL if either array pointer is NULL.
// Return NULL if the number of entries is <= 0.
int *create_array_of_products( int *p_first, int *p_second, int
number_of_entries )
{
return p_first ; // Fix this -- this value
causes all unit tests to fail.
}
// Calculate the total of all of the entries in the passed array
and return that total.
// Return a zero if the passed array (pointer) is NULL or the
number of entries
// is less than or equal to 0.
// Only free the passed pointer if it is not NULL and the number of
entries is greater than 0.
// hint: be sure to free the passed pointer only as described
above!
int get_total_and_free( int *p_array, int number_of_entries )
{
return -1 ; // Fix this
-- causes all unit tests to fail.
}

I hope you understand my code i am puting
Screen shoots with output also....feel free to ask me in comments
and please like my answer....It will give me motivation.....
// Using malloc create an array that contains the product of the each element in *p_first...
-Create a function output() in C that takes the pointer to the array and its size and prints the arrays' contests. (malloc format) (function prototype : void output(int *arrayPtr, int size); -Create a function check() in C that takes the pointer to the array and a number and checks if the number is in the array. If the number is in the array, returns the index of the element of the array holding the number. Otherwise, returns -1.
Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int * ) named ptr_1. Use ptr_1 to assign the number 7 to that dynamically allocated integer, and in another line use printf to output the contents of that dynamically allocated integer variable. Write the code to dynamically allocate an integer array of length 5 using calloc or malloc and have it pointed...
Malloc function
For the prelab assignment and the lab next week use malloc
function to allocate space (to store the string) instead of
creating fixed size character array. malloc function allows user to
allocate memory (instead of compiler doing it by default) and this
gives more control to the user and efficient allocation of the
memory space.
Example
int *ptr
ptr=malloc(sizeof(int)*10);
In the example above integer pointer ptr is allocated a space of
10 blocks this is same as creating...
(C++ program )Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument array should be copied to the element 1 of the new array. Element 1 of the argument array should be copied to element 2 of the new array, and so forth....
Using C, create a data file with the first number being an integer. The value of that integer will be the number of further integers which follow it in the file. Write the code to read the first number into the integer variable how_many.Please help me with the file :((This comes from this question:Write the code to dynamically allocate ONE integer variable using calloc (contiguous allocation) or malloc (memory allocation) and have it pointed to by a pointer (of type int...
HW58.1. Array Merge Sort You've done merge (on Lists), so now it's time to do merge sort (on arrays). Create a public non-final class named Mergesort that extends Merge. Implement a public static method int[] mergesort(int[] values) that returns the input array of ints sorted in ascending order. You will want this method to be recursive, with the base case being an array with zero or one value. If the passed array is null you should return null. If the...
in the c programming language. List *init() { head = ( List * ) malloc( sizeof( List ) ); if ( head == NULL ) { prtError( "Insufficient memory!" ); return( NULL ); } head->data = -1; head->next = NULL; tail = head; return ( head ); } /* Insert a new data element d into the list. */ /* Insert at the front of the list, right behind the dummy node. */ /* Return NULL if a new node...
using c++
13 do pretty much whatever they want Exercise: Array Resizing You will create an array manipulation program that allows the user is to pre much whatever meant to ananas Wananching the program the user will passat are the contains a set of value and that w 2 Check to see the could be opened at the program was not opened the continue 3. Create an array and with the values from Presente en de h and powermany reded...
C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array named f, and one double array named d, each of size M. (b)Declare array x with N of those structs. (c)Write a void function to traverse array x (using a pointer) assigning to each element in each array d (in each struct in array x) the sum of the corresponding elements in arrays i and f (in the same struct). Use 3 pointers (of...
using C++ only. The findFirstZero function is supposed to find the first element in an array whose value is zero, and sets the parameter p to point to that element, so the caller can know the location of that element holding the value zero. Explain why this function won't do that, and show how to fix it. Your fix must be to the function only; you must not change the main routine below in any way. As a result of your fixing...