#include <stdio.h>
int appendArray(int array1M[], int iCount1, int array2M[], int iCount2, int iMaxArray1) {
if (iCount1 + iCount2 > iMaxArray1) {
printf("Sorry, there are not enough empty spaces in array1M!!");
return iCount1;
}
for (int i=0; i<iCount2; i++) {
array1M[i + iCount1] = array2M[i];
}
printf("Contents of array1M after appending is: \n");
for (int i=0; i<iCount1 + iCount2; i++) {
printf("%d ", array1M[i]);
}
return (iCount1 + iCount2);
}
int main(void) {
int iCount1 = 3, iCount2 = 2;
int array1M[8];
array1M[0] = 11;
array1M[1] = 12;
array1M[2] = 13;
int array2M[iCount2];
array2M[0] = 24;
array2M[1] = 25;
printf("\n\nNew size of array1M = %d", appendArray(array1M, iCount1, array2M, iCount2, 8));
return 0;
}
Must be in C. 2. Show code for function, appendArray, based on the following prototype: int...
In c++ code and test a function with prototype float except(int arg); that accepts an int argument and returns the expression 1.0 / arg if arg != 0; otherwise, except() throws an exception of type string. A suitable message might be “Error – attempt to divide by zero”.
Write function in C++: int removeDups (string a[], int n); For every sequence of consecutive identical items in a, retain only one item of that sequence. Suppose we call the number of retained items r. Then when this function returns, elements through of a must contain the retained items (in the same relative order they were in originally), and the remaining elements may have whatever values you want. Return the number of retained items. Here's an example: string [9] =...
answer in c++ Using the table below, complete the C++ code to write the function prototype statement, and the void function header. The void function should receive three double variables: the first two by value and the last one by reference. Name the formal parameters num1, num2 and answer. The function should divide the num1 variable by the num2 variable and then store the result in the answer variable. Name the function calcQuotient. Also write an appropriate function prototype for...
Question 14; Write a C function named isSymmetric, the prototype of which is given below, that returns 1 if the elements of an array of integers named myArray of size n are symmetric around the middle. If the array elements are not symmetric, the function should return 0. Both the array and its size are specified as parameters. (10 marks) Clue: Array myArray of size n is symmetric if myArray[0] is equal to myArray[n-1], myArray[1] is equal to myArray[n-2], and...
Help with these questions A function rectarea has already been defined with this prototype: int rectarea(int width); It collects an integer height from the user and returns the area of the resulting triangle; Write code that will call rectarea twice with values 5 and 10, and print the results obtained. Warning: in a composed function like "f(a),b0);", you don't know whether a) will be called first or b(!. The variable age has been defined as an integer. Write code which...
write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...
using C: Write code for a function with the following prototype: /* * Mask with least signficant n bits set to 1 * Examples: n = 6 --> 0x3F, n = 17 --> 0x1FFFF * Assume 1 <= n <= w */ int lower_one_mask(int n); Your function should follow the bit-level integer coding rules. Be careful of the case n =w.
(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....
C++ Recursion Code a function which displays the first n prime numbers. The prototype is: void prime (int) The number of primes to display is passed as the parameter. The function prime itself is not recursive. However, it should call a separate recursive helper function which determines if a given number is prime #include <iostream> using namespace std; void prime(int ) { } int main() { prime (21); return 0; }
What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...