6. Write a swap function, that swaps the values of two variables in main, but use pointers instead of reference parameters. 7. Write a function that takes an array of ints and its size as arguments. It should create a new array that is the same size as the argument. It should set the values in the new array by adding 10 to each element in the original array. The function should return a pointer to the new array. (Make sure you use dynamic memory allocation) can i get answers for this two sub parts. thanks
Q: Write a template function that returns the average of all the elements of an array. The arguments to…
A: PROGRAM STRUCTURE: Include the required header files for using various functions. Include iostream…
Q: Given the code segment below, what should be the data type of a in the function prototype of…
A: The main function call is func(aData[4]) Here the function name is func and passed parameter is a…
Q: Write a function resize(.) that dynamically resizes an array of integers by a specified amount in…
A: C++: It is a general purpose programming language. It is extension of C program. It is efficient…
Q: Write a function to concatenate the content of two dynamic integer arrays. Your function should…
A: Declare the array globally for concatenation if you don't want to use any of in-built string…
Q: How do you assign a variable’s address to a pointer variable? What is wrong in the following code?
A: Given:- How do you assign a variable’s address to a pointer variable? What is wrong in the following…
Q: 3. What will be size of the following pointers? What are their scalar values? Explain with…
A: The size of a pointer is not fixed. It depends upon Operating system, CPU architecture etc. Usually…
Q: Suppose that an array is passed as a parameter. How does this differ from the usual use of a value…
A: We usually declare an array using the following statement... int a[]; After this statement, the…
Q: Write a function C++ void switchEnds(int *array, int size); that is passed the address of the…
A: I have provided C++ CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT----------------
Q: Given the code segment below, what should be the data type of a in the function prototype of…
A: Here the data type of a in the function prototype of func() should be double. This is because in the…
Q: 2. Write a program which sorts the CGPA array having cgpa of all students in ascending order by…
A: The program is written in C
Q: Write a C++ function that takes two integer arrays and adds each element of both arrays using…
A: /*Program to add two intger arrays using pointer*/ //include standard input/output header #include…
Q: Please write C++ functions, class and methods to answer the following question. Write a function…
A: The code is given below.
Q: Write a program to swap the values of 2 arrays using pointers. Create a function (void inputArray)…
A: Required:
Q: Which of the following statements is NOT correct? Select one: O a. You can define const array…
A: Yes, we can define const array parameter in a function to prevent it from being changed.
Q: Part 1 Write a C/C++ function that will receive a pointer to the address of the first element of…
A: C++ program Code: #include<iostream>#include<fstream>using namespace std;int…
Q: 23. What is wrong with the following function definition? double * calculate (double a, double b) {…
A: The answer is given below.
Q: Write a code that contains a function which finds the minimum element of an array of unsigned…
A: A data type holding numbers are signed by default and can represent both positive and negative…
Q: Write a Program in C to copy the contents of a one-dimensional character array into another…
A: According to the information given:- We have to follow the copyArrayIndecWay() and copyPointerWay()…
Q: When should a pointer parameter p be a reference parameter? Group of answer choices When the…
A: We need to select the correct choice of when should a pointer parameter p be a reference parameter.
Q: C++ By defining a dynamic allocation for pointer array, ask the user to enter some numbers and then…
A: Solution - What is a Dynamic Array? A dynamic array is quite similar to a regular array, but its…
Q: Show (in code) the 4 ways you can initialize a pointer (depending on what you want to allow to…
A: Introduction of Pointer: In programming language pointer stores memory address and it is the most…
Q: 2.5) write a function called SwapPointers() in order to interchange pointers(pp)and qq so that arter…
A: Input : Given two-pointers: pp and qq. Output : Swap two-pointers contents.
Q: 2. Write a C program to implements a user-defined function which will take an array and an integer…
A: The C program along with the snapshot of code and output is given below:
Q: Write a definition for pointer variables that will be used to point to dynamic arrays? The array…
A: A pointer variable is similar to the other variables that may be used to store data. A pointer,…
Q: function that returns a pointer to the maximum value of an array of double.
A: Given data is shown below: Write a function that returns a pointer to the maximum value of an array…
Q: Write a function, remove, that takes three parameters: an array of integers, the number of elements…
A: Given: Write a function, remove, that takes three parameters: an array of integers, the number of…
Q: Write a function in C++ which (normally) allocates new space for a double array. It should alter its…
A: #include <iostream> using namespace std; // Defining the allocation functionvoid…
Q: 5- Write a C program that defines a set of functions that do the following: Reading elements of any…
A: Algorithm: Step-1: Start Step-2: Create an array 'ar' of size 50 and take variable n Step-3: Take…
Q: In C: Create a program that allocates an array of integers frees them, and then tries to print the…
A: “free” methоd in С is used tо dynаmiсаlly de-аllосаte the memоry. The memоry аllосаted…
Q: By using C , void fun(void* a, char*b) Write a defination of above function that accepts a…
A: pointers: pointers in c which will store the address of another variable , it used to refer another…
Q: Write a Template function body called swap( ) to swap the values of the two values of integer,…
A: The syntax for the template function is shown below. template<class T>return_type…
Q: Description Please finish the following function char *replace(charsource, char constpattern, char…
A: required function: char *replace(char *source, char const *pattern, char const *replacement){…
Q: 1. Write a function called void swap with two parameters, which will receive the address of x and y…
A: The function will take two arguments of pointer type and swap the actual address of variables…
Q: 2/ Write a code that will read two integer numbers and then call a function (swap) to interchange…
A: "Since you have not mention any programming language, so we will write this program in C language."…
Q: Write a function that gets an array as a parameter (address and size) and a number and checks to see…
A: PROGRAM: //Header file #include <stdio.h> //Defining the findnReport() function void…
Q: 1. Inspect the code and in your own interpretation, describe the reason call to function…
A: NOTE: - Since it is a multipart question, hence only the first three parts are answered below.…
Q: In C++, Can you please look at the code below and revise/fix so it will work according to…
A: Solution: Note : The code you attached is running file and executing properly. Note : I also…
Q: Question 3: Suppose that you have the following declarations: int times[30][7]: int speed[15][7]:…
A: Since array data is not mentioned, I am assigned random data. Code: #include <iostream>using…
Q: Creat a code in c++ using s class compute array By using pointer notation, write a program that have…
A: Program code: #include <iostream> using namespace std; //by using pointers we need not return…
Q: 5.b. How do you define and use double indirection pointers, pointer to array and array of pointers?…
A: In C programming, pointers are used to hold the address value of a variable that can be declared in…
Q: Write a function that reorders the values in two integer variables such that the values are in…
A: void reorder(int *a, int *b){ int temp; if(*a > *b){ temp = *a; *a = *b;…
Q: 1. single element of an array can be passed to the function? true or false. 2. Array can be…
A: Note: there are multiple questions asked.solving the first three,re-post remaining or specify…
6. Write a swap function, that swaps the values of two variables in main, but use
pointers instead of reference parameters.
7. Write a function that takes an array of ints and its size as arguments. It should
create a new array that is the same size as the argument. It should set the values in
the new array by adding 10 to each element in the original array. The function
should return a pointer to the new array. (Make sure you use dynamic memory
allocation)
can i get answers for this two sub parts. thanks
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- 1. Write a function called void swap with two parameters, which will receive the addressof x and y as pointer. The function should swap the value of x and y only if x is larger thany. Print the value of x and y after the function call. 2. Write a function called double getAverage(int *array, int SIZE), whereit accept the array as pointer, and return the average of the array. Print the returnedvalue from this function. Always use *array rather than subscript to access the arrayvalue.Create a dynamic array that contains an int array. dynamic array, array inside when the existing array is full and a new element needs to be added will double its size, make all the elements of the old array the same will copy the indexes and add the element to the new array. Use the following functions. Write in C language. 1.append(dynamic array, new element): function sent to itself Adds the element sturct to the end of the array inside DynamicArray. Place If not, it behaves in accordance with the dynamic array definition given above. 2. get(index): The element in the index sent to it by the function takes it from the array it hosts and sends it back. ATTENTION ! : Please use a dynamic array and this array with struct structure. I don't want a link list. Do not post wrong or copied codes. Be sure to use the append and get functions given above Please do not solve the question I asked with the same code and copy and paste the code, my right to the question is running out. Solve the…Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is two elements larger than the argument array. The first two elements of the new array should be set to 0. Element 0 of the argument array should be copied to element 2 of the array, element 1 of the argument array should be copied to element 3 of the new array, and so forth. The function should return a pointer to the new array. Demonstrate the function in a complete program.
- Create a dynamic array that contains an int array. dynamic array, array inside when the existing array is full and a new element needs to be added will double its size, make all the elements of the old array the same will copy the indexes and add the element to the new array. Use the following functions. Write in C language. 1.append(dynamic array, new element): function sent to itself Adds the element sturct to the end of the array inside DynamicArray. Place If not, it behaves in accordance with the dynamic array definition given above. 2. get(index): The element in the index sent to it by the function takes it from the array it hosts and sends it back.Create a dynamic array that contains an int array. dynamic array, array inside when the existing array is full and a new element needs to be added will double its size, make all the elements of the old array the same will copy the indexes and add the element to the new array. Use the following functions. Write in C language. 1.append(dynamic array, new element): function sent to itself Adds the element sturct to the end of the array inside DynamicArray. Place If not, it behaves in accordance with the dynamic array definition given above. 2. get(index): The element in the index sent to it by the function takes it from the array it hosts and sends it back. Do not use link lists. Solve the question using array. Use it as a struct DynamicArray.Create a dynamic array that contains an int array. dynamic array, array inside when the existing array is full and a new element needs to be added will double its size, make all the elements of the old array the same will copy the indexes and add the element to the new array. Use the following functions. Write in C language. 1.append(dynamic array, new element): function sent to itself Adds the element sturct to the end of the array inside DynamicArray. Place If not, it behaves in accordance with the dynamic array definition given above. 2. get(index): The element in the index sent to it by the function takes it from the array it hosts and sends it back. Do not use link lists. Solve the question using array.
- Write a function void switchEnds(int *array, int size);that is passed the address of the beginning of an array and the size of the array. The function swaps the values in the first and last entries of the array.Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named data into an array. The program then passes the array to your array expander function, and displays the values of the new expanded array, one value per line. You may assume that the file data has at least N values. There are no prompts for the integer and no labels for the expanded reversed array that is printed out. If the integer read in from standard input exceeds 50 or is less than 0 the program terminates silently.Create a function that accepts an array of pointers as an argumentCreate one function that contains only one for loop to print the passed array of pointer.So, lines from //A to //B need to be replaced with only two function calls: one function call to printmonths (from the month array), and the second function call for printing the days (form the dayarray). Both function calls are for the same function but with different parameters.
- write in c++ Write ONE program that contains the following (#includes are NOT necessary). [Hint: be very careful with your pointer syntax] Write a function copies with two int parameters, named n and x. It should dynamically allocate a new array of size n. The function should then copy the value in x to every position in the array. The function should return a pointer to the new array. In the main function, call the copies function from part 1. with size 5 and value -1. Output the resulting array to the screen, and deallocate the array. In your main function, add code to declare and initialize two integer variables y and z to 10 and 3. Then call the function increment which has the prototype below. The call should result in incrementing the value in y by z (so y will become 13). void increment (int *a, int b); //do NOT define this function// this function adds b to the value pointed to by the first argument1. Write a Swift function that takes an array as a parameter and returns a boolean value whether the value 0 is present in the array or not.8. using c++, Write a function method that determines the mean of all the values in an array of integers. Your mean function should call a separate function that you write that determines the sum. Don’t use built-in sum or mean gadgets, but roll your own.