C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Write a function prototype and a function definition called average that receives an array of type integer, and the number of elements in the array.
It returns the average of the numbers in the array.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Write a function prototype and a function definition called sum that receives an array of type integer, and the number of elements in the array. It returns the sum of the numbers in the array.arrow_forwardPlease code in C. Write a user defined function and a main function with the function call. Write a user-defined function ExpensiveFlights that takes at least 2 arguments, an array of doubles called fares, containing airline prices, and an int variable count that contains the number of elements in fares. The function should compute and return the average of the fares and also return (input/output parameter) the count of how many fares are greater than 800. Write the main function with the function call to ExpensiveFlights. Don’t declare pointer variables in the main function.arrow_forwardWrite a C++ function definition named containsNumber. The function should take three parameters: a one-dimensional integer array, the number of entries in the array, and an integer value. The function should search the array for the integer value and return a boolean value of true if the value is found and false otherwise. Below is a example call to the function: valueFound = containsNumber(table, nbrOfEntries, value); You may assume that all parameters passed to the function are valid, that the nbrOfEntries amount is always greater than or equal to one, and that a specific integer value occurs at most once in the table. Remember to only write the function definition for the containsNumber function. Do not write a complete C++ program.arrow_forward
- In C++ Write a function header ( and only function header ) for the following: Function named printArray() that returns nothing, and that takes two parameters: an array of integers named testScores [ ] an integer named SIZE .arrow_forwardC++ Write a definition of a function called MAX which receives an integer array and its size parameters. It will return the max value of the parameter array.arrow_forwardUsing C++ Programming language: Assume you want a function which expects as parameters an array of doubles and the size of the array. Write the function header that accepts these parameters but is defined in such a way that the array cannot be modified in the function. You can use your own variable names for the parameters.arrow_forward
- For Assignment 5, you will design and write a program that covers the following topics: Functions, Vectors, Structures, and Classes. Functions & Passing Variables: Write a different function for each type of variable used. The functions should provide some sort of output through a cout or return value. Normal variable: Passing a variable by value to a paramater of a function. Show that this only makes a copy of the variable passed to it. Normal variable with a default value: Set a default value for a function parameter. Show how the default value gets used. Reference variable: Passing a variable by reference to a parameter of a function. Show how a reference variable can change the value of variable in main(). Show how the use of const can make a reference variable safer (think of it in terms of read/write). Pointer variable: Passing an address of a variable to a parameter of a function. Show how a pointer can change the value of a variable in main(). Show…arrow_forwardC++ programarrow_forwardC++arrow_forward
- Write a value-returning function that receives an array of structs of the type defined below and the length of the array as parameters. It should return as the value of the function the sum of the offspring amounts in the array. Note: you do not need a main function or to create an array. Assume the array already exists from main. #include <iostream>using namespace std; // struct declaration for Animal struct Animal { // a string for animal typestring animal_type;// a string for color string color;// an integer for number of offspring. int number_of_offspring;}; // Main function to declare a structure variable of type Animal. int main(){struct Animal A1;return 0;}arrow_forwardWrite a function which accepts an int array and the number of elements in the array as two parameters. The function should dynamically create a new int array that is one element larger than the argument array. Element 0 of the new array should contain size, i.e. the number of elements in the argument array. Element 0 of the argument array should be copied to Element 1 of the new array, Element 2 of the argument array should be copied to Element 1 of the new array, etc. The function should return a pointer to the new array and should not modify the argument array. You may assume that the argument array contains at least one valid element and size is the number of elements in the array. You do not need to demonstrate calling this function. Example: if a[] is {2, 7, 4}, and size is 3, the function should return a pointer to a new array with 4 elements containing {3, 2, 7, 4}. int *counter(int a[], int size)arrow_forwardWrite in C++ Sam is making a list of his favorite Pokemon. However, he changes his mind a lot. Help Sam write a function insertAfter() that takes five parameters and inserts the name of a Pokemon right after a specific index. Function specifications Name: insertAfter() Parameters (Your function should accept these parameters IN THIS ORDER): input_strings string: The array containing strings num_elements int: The number of elements that are currently stored in the array arr_size int: The number of elements that can be stored in the array index int: The location to insert a new string. Note that the new string should be inserted after this location. string_to_insert string: The new string to be inserted into the array Return Value: bool: true: If the string is successfully inserted into the array false: If the array is full If the index value exceeds the size of the arrayarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr