Write a C++ function (call it index_max) that finds the maximum number in a 1-D array of floats, that is passed to the function, and returns the max number and its index. For example, if you pass [5.1, 6, 8.5, 9, 5.6, 2.7] to the function, you obtain 9 and 3. Write a C++ program and test your function. Take the following note into consideration when writing your program: • The function should prevent changing the elements of the passed array.
Q: write a c++ program for the following Write a function called mirror_add that takes two 2D arrays…
A: mirror_add function: //Function definitionvoid mirror_add(int first[2][3], int second[2][3]){…
Q: Q4: Write a program in C++ to read a two dimensional array X[2][3] from keyboard, send it to…
A: The absolute value of any number is positive. So if the entered number is positive then its absolute…
Q: Write a C++ function, lastLargestIndex, that takes as parameters an int array and its size and…
A: 2. Program: #include <iostream> using namespace std; int lastLargestIndex(int a[], int size);…
Q: what if i needed to add a third value to this like address? would it then be a void function? how…
A: Introduction Float basically demonstrates about to find a value in a decimal format that is not in…
Q: Write a C program to take in 10 integers from the user and populate a 1-D array, and then sort the…
A: The required C code is : #include <stdio.h> int main(){ int i,min=0,m,temp,k,cnt=0; int…
Q: Let us call a 2-dimensional array of integers a magic matrix if the following conditions are true.…
A: The program randomly reads integer numbers between -44 to 66 using rand() function. The array is a…
Q: Write a C++ function that returns the sum of the max and min elements of 1-D array of floats. Then,…
A: Write a C++ program that returns the sum of the max and min elements of 1-D array of floats with the…
Q: Write a C++ program that will implement and test the five functions described below that use…
A: #include <iostream> using namespace std; int findLast(int *array, int size, int targetValue) {…
Q: Write c++ program and test the following functions : void multiply (float a[ ], int n, float b [ ]…
A: #include<iostream.h>#include<conio.h>void multiply(float a[],int n,float b[]);void…
Q: Write a C++ function, bool ok(int q[]), which takes an array q and returns true if the array…
A: Given: Write a C++ function, bool ok(int q[]), which takes an array q and returns true if the…
Q: Write a C++ function to get an integer array and its size as parameters, then find and return the…
A: Objective: This program uses a function whose prototype is given as, int avgarray(int a[], int…
Q: write a function that gets 3 pointers int* a, int* b, int* c, and rotates the values in their…
A: note that a gets the value of b and we are working on pointers here so a will loose its originality.…
Q: Write a C program that has the following functions: Time left 0:43:4- Function 1: Ask the user to…
A: Given question has asked to create a program in c Input student grades until -1 is entered. grade…
Q: Write a c++ program to Declare an array of 10 elements dynamically and initialize each element (from…
A: Algorithm: Step1: Declare array size. Then declare the array dynamically. In our case…
Q: Write a C++ programme with an arrays function : please provide step by step guide In many…
A: Input : 10 float values from the user. Output : The average and standard deviation of the input…
Q: Write a C++ program to read a size of an array (F) and then read the array elements from the user to…
A: Program I) #include <iostream>using namespace std; int main () { int i,F;…
Q: Write a function SWAP (int ARR[ ], int Size) in C+ to modify the content of the array in such a way…
A: The Answer is
Q: Write a C++ function, smallestIndex, that takes as parameters an int array and its size and returns…
A: algorithm define size of array as 15 for a loop for size of array take input from user take index…
Q: In C++ Consider an array of size n. Write a function that takes n values as input for the array,…
A: C++ code: #include <iostream> using namespace std; //function to swap adjacent elements void…
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: Write a program in C++, which has a function to swap/exchange elements of two arrays of type float…
A: #include <iostream> using namespace std;int exchange(float *arr1, float *arr2, int N){int…
Q: Write a function, largestIndex, that takes as parameters an int array and its size and returns the…
A: The searching of the largest element in the array : Assume that the starting element at index, 0 is…
Q: Write a C program to interchange smallest and largest element in the array with following function…
A: In this question we need to write a C code to take array elements from user and interchange the…
Q: Write a C++ program that takes an char array of size twenty. Take input a sorted array from the…
A: Sample Response: //C++ programming language#include <iostream> using namespace std;//main…
Q: Write a program in c languageto find the sum of all non-prime numbers from m and n (including m and…
A: Prime number: A number is said to be a prime number if the number of divisors of the numbers is…
Q: Write a C function that is given a pointer to memory, the number of bytes of memory the pointer…
A: Code: #include<stdio.h> #include<stdint.h> //Treat ptr as the base address of a…
Q: Q4: Write a program in C++ to read a two dimensional array X[2][3] from keyboard , send it to…
A: /*C++ program to input two dimension array, find absolute value and display negative/positive…
Q: write a C program. Declare a 1D array of n elements. Then input values in array in such a way that…
A: Program: #include <stdio.h> void Shift_Array(int id[5],int size){ int n; for(int…
Q: Write a C++ function that returns the sum of the max and min elements of 1-D array of floats. Then,…
A: To write the code.
Q: Write a program in C language that will calculate the norm of a vector in a function. Use single…
A: C code: #include <stdio.h>#include <math.h> //function declarationint ComputeNorm(int[],…
Q: Write a C++ program to declare an array A={3, -7, 12, -4, 5, -2} and pass it to a void-type function…
A: C++ Function to find max, min and average of the array values given.
Q: Write a C++ program that take five input by user in an array and pass it to function. Find the…
A: Below is the required C++ program: - Approach: - Importing the header files and using the…
Q: Write a C++ program for the following In this task, your job is to create a function Swapper() that…
A: #include <iostream>using namespace std;void Swapper(int &num1,int *num2,int…
Q: Write a C program which is a function printArrayReverse(int* arr, int size) that uses a pointer to…
A: Answer : #include <stdio.h> #define MAX_SIZE 100 struct reverseArray { int…
Q: Write a C function to search for a given number using binary search in a given array of sorted…
A: Given: Write a C function to search for a given number using binary search in a given array…
Q: Given the following, write a line of code that will initialize p to point to the “7” in the array).…
A: #include <stdio.h> int main(){ unsigned char x[] = {2, 3, 5, 7, 11, 13, 17}; unsigned…
Q: Write a function f which takes three pointers to int variables (a, b, c). Then it should: -Set the…
A: "Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: Write a C++ program that defines an integer array of size 18, the program asks the user to fill the…
A: Ans: Code:
Q: Modify the below program in c++ to give the correct output :- void array(int a[]) { cout « sizeof(a)…
A: The solution to the given problem is below.
Q: Write a C++ program that asks the user to enter values in a 1d array. The size of the array should…
A: The ask is to write a C++ program which does the following: - user input for size of the array. -…
Q: Write a C function (only a function) that takes an array of integers called arr and the array size…
A: Program Approach: Including a necessary header file Declare a function to reverse array elements…
Q: Write a C++ program for the following Write a function Average() that receives a pointer to an…
A: steps input: Array of elements output: Average of array numbers Read the elements declare function…
Q: Write a program in C++ which takes two 4 x 4 matrices as input from the user and displays the…
A: PROGRAM CODE: #include <iostream> // include header file for input output stream…
Q: Let us call a 2-dimensional array of integers a magic matrix if the following conditions are true.…
A: We have to take input of the 6*9 array using the method readArray. We have to print the array using…
Q: Write a C function countEven() that takes an integer array and the number of elements in the array…
A: The function countEven() will be defined as follows: The parameters are an array and the size of…
Q: Write a C program that uses arrays and functions to implement a calculator for two operands. Your…
A: #include <stdio.h> #include<string.h> #include<math.h> //Declare global variable…
Q: Write a program in C++ to calculate the positive difference between two one dimensional array of 20…
A: Read the numbers in two one dimensional array. Find the difference between the two corresponding…
Q: Write a c++ code that swaps two input integers using pointers. a. In the main function. b. By…
A: As i have read guidelines i can provide answer of only 1 part of questions in case of multiple…
Q: Write a C++ function that returns the sum of the max and min elements of 1-D array of floats. Then,…
A: Make the array as constant in function so that no updating can be done
Step by step
Solved in 2 steps with 3 images
- Q2: Write a C++ function (call it index_max) that finds the maximum number in the array, that is passed to the function, and returns the max number and its index. For example, if you pass [5,6,8,9,5,2] to the function, you obtain 9 and 3. Write a C++ program and test your function. Take the following notes into consideration when writing your program: 1- Your function should work with any data type. 2- The function should prevent changing the elements of the passed array. 3- You are not allowed to use materials that are not covered in our lectures.Complete the following function using pass-by-reference: void findMax(int &max, int a) which assigns value ‘a’ to ‘max’ if a > max. Write a pseudo-code then implement a program in C language to find the maximum in a sequence of numbers using this function.C Programming Problem : Write a C program with a function that takes an integer value (1 <- integer value < 9999) and returns the number with its digits reversed. For example, given the number 6798, the function should return 8976. Those two- original number and reversed number- numbers will pass to another function as parameters and calculate their sum. The program should use the function reverseDigits to reverse the digits and SumOriginalReverse to calculate their sum. Your output should appear in the following format: Output reverse digiS 4321 Main Enter a number between 1 and 9999: 6798 The number with its digits reversed is: 8976 6798 + 8976 - 15774 12.34 JomoriginalRevers Enter a number between I and 9999: 6655 The number with its digits reversed is: 5566 6655 + 5566 = 12221 Enter a number between 1 and 9999: 8 The number with its digits reversed is: 8 8 + 8 = 16 Enter a number between 1 and 9999: 123 The number with its digits reversed is: 321 123 + 321 = 444 Enter a number…
- Computer Science In C++ use the following STL algorithms: reverse, rotate, and shuffle. Write versions of these functions using the same parameters as the original functions but using your own definition of the function body. Use each function at least three different times in a test program to make sure the function operates properly. The data sets you use for testing should contain at least twenty elementsC Program: An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3. I have written a function called isPerfect (see below), that determines whether parameter passed to the function is a perfect number. Use this function in a C program that determines and prints all the perfect numbers between 1 and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect. // isPerfect returns true if value is perfect integer, // i.e., if value is equal to sum of its factors int isPerfect(int value) { int factorSum = 1; // current sum of factors // loop through possible factor values for (int i = 2; i <= value / 2; ++i) { // if i is factor if (value % i == 0) { factorSum += i; // add to sum } } // return true if value is equal to sum of factors if (factorSum == value) { return…Write a complete C++ code that inputs a character array (string) from a user. After taking input it callsa function Reverse() that reverses the string word by word as shown below:Original Character Array:Raining in summers makes your life prettyAfter calling Function Reverse():pretty life your makes summers in RainingNote: You have to use pointers in the function. You can use any builtin Cstring function of your choice for thistask.
- Write a C user defined function array and a value which you want to find in the array. (function may be needs more parameter to perform it) The function should check values of the array and if it find the same value in the array, it should return the position in the array (just first one). If there is no match, it should return "-1" Example: if array is {1,2,5, 3, 10, 5) and if the search term is "10" function must return 4, If the search term is "5" function must return 2, If the search term is "9" function must return -1,Write a c++ program: Write a function named convertToLowestTerms that inputs two integer parameters by reference named numerator and denominator. The function should treat these variables as a fraction and reduce them to lowest terms. For example, if numerator is 20 and denominator is 60, then the function should change the variables to 1 and 3, respectively. This will require finding the greatest common divisor for the numerator and denominator then dividing both variables by that number. If the denominator is zero, the function should return false, otherwise the function should return true. Write a driver program that uses convertToLowestTerms to reduce and output several fractions.in c programming with User-Defined Functions Swapping variables Define a function named SwapValues that takes four integers as parameters and swaps the first with the second, and the third with the fourth values. Then write a main program that reads four integers from input, calls function SwapValues() to swap the values, and prints the swapped values on a single line separated with spaces. Ex: If the input is: 3 8 2 4 function SwapValues() returns and the main program outputs: 8 3 4 2 The program must define and call a function:void SwapValues(int* userVal1, int* userVal2, int* userVal3, int* userVal4)Function SwapValues() swaps the values referenced by the parameters.
- Write in C++ When you're processing data, it’s useful to break up a text string into pieces using a delimiter. Write a function split() that takes a string, splits it at every occurrence of a delimiter, and then populates an array of strings with the split pieces, up to the provided maximum number of pieces. Function specifications: Name: split() Parameters (Your function should accept these parameters IN THIS ORDER): input_string string: The text string containing data separated by a delimiter separator char: The delimiter marking the location where the string should be split up arr string array: The array that will be used to store the input text string's individual string pieces arr_size int: The number of elements that can be stored in the array Return Value: int: The number of pieces the input text string was split into Note: No input will have delimiters in the beginning or the end of the string. (Eg: ",apple, orange" OR "apple, orange,") No input will have multiple…Write C++ Program to determine the max numbers between 2 arrays. For example: 6. 1 34 7 2 0 11 20 Result 7 3 1 11 34 To resolve this problem, you should write 3 void functions: inputNumbers, testArrays and displayMaxArray. • inputNumbers: the aim of this function to read 10 numbers from the user and insert them in 2 different arrays (length of the array is 5). • testArrays: determine the max numbers between 2 arrays. • displayMaxArray: print the array containing the max numbers. Write C++ Program to check whether the Given String is a Palindrome. To resolve this problem, you should write 3 void functions: inputStrings, testPalindrome and displayNumbers. • inputStrings : the aim of this function to read 7 strings from the user and insert them in array of 7 elements. • testPalindrome: to check whether the given strings in the array are palindrome. displayPalindrome: print the palindrome strings.C Program Functions using Pointers Create a function modify that accepts an integer and divides the integer by 2 if it is even. If the integer is odd, add one and divide it by 2. The function does not return anything. In the main function, write a program that asks for an integer input and call the modify function by passing in the reference of that variable as a parameter. An initial code is provided for you. Just fill in the blanks. Input 1. One line containing an integer input Output Enter a number: 5 Before: 5 After: 3