Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
9th Edition
ISBN: 9780133862225
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 7.4, Problem 22STE
Explanation of Solution
Function definition:
//Function definition
void echo(const int a[][5], int len)
{
//Loop for rows
for (int i = 0; i < len; i++)
{
//Loop for columns
for (int j = 0; j < 5; j++)
{
//Print the result
cout << a[i][j] << " ";
}
//Print statement
cout << endl;
}
}
Explanation of above function:
- The function “echo()” is defined with “void” return type.
- It has two arguments. One is a constant array variable with size of column and another one is size of the array.
- Using “for” loops, the array values are printed in screen.
Program with function definition:
/*Include the appropriate headers*/
#include<iostream>
using namespace std;
//Function definition
void echo(const int a[][5], int len)
{
//Print statement
cout<<"Array values:\n";
//Loop for rows
for (int i = 0; i <...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a definition for a void-function that has two int value parameters and outputs to the screen the product of these arguments. Write a main function that asks the user for these two numbers, reads them in, calls your function, then terminates. c++
Write the function prototype of the void function named G() that takes an int reference parameter and two char parameters respectively
Your answer
Write a function to divide variable ‘a’ with ‘b’. Store the result in a separate variable andreturn it from the function. Practice default parameters by calling your function with 1 argumentand with 2 arguments. Use the concept of function prototyping for this question. The signature offunction is as follows: int divide (int a, int b=2)
Chapter 7 Solutions
Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
Ch. 7.1 - Prob. 1STECh. 7.1 - In the array declaration double score(5); state...Ch. 7.1 - Identity any errors in the following array...Ch. 7.1 - What is the output of the following code? char...Ch. 7.1 - What is the output of the following code? double a...Ch. 7.1 - What is the output of the following code? int i,...Ch. 7.1 - Prob. 7STECh. 7.1 - Suppose we expect the elements of the array a to...Ch. 7.1 - Prob. 9STECh. 7.1 - Suppose you have the following array declaration...
Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Prob. 12STECh. 7.2 - Write a function definition for a function called...Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Insert const before any of the following array...Ch. 7.2 - Write a function named outOfOrder that takes as...Ch. 7.3 - Write a program that will read up to ten...Ch. 7.3 - Write a program that will read up to ten letters...Ch. 7.3 - Following is the declaration for an alternative...Ch. 7.4 - Prob. 20STECh. 7.4 - Write code that will fill the array a (declared...Ch. 7.4 - Prob. 22STECh. 7 - Write a function named firstLast2 that takes as...Ch. 7 - Write a function named countNum2s that takes as...Ch. 7 - Write a function named swapFrontBack that takes as...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - There are three versions of this project. Version...Ch. 7 - Hexadecimal numerals are integers written in base...Ch. 7 - Solution to Programming Project 7.3 Write a...Ch. 7 - Prob. 4PPCh. 7 - Write a program that reads in a list of integers...Ch. 7 - Prob. 6PPCh. 7 - An array can be used to store large integers one...Ch. 7 - Write a program that will read a line of text and...Ch. 7 - Write a program to score five-card poker hands...Ch. 7 - Write a program that will allow two users to play...Ch. 7 - Write a program to assign passengers seats in an...Ch. 7 - Prob. 12PPCh. 7 - The mathematician John Horton Conway invented the...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - A common memory matching game played by young...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Prob. 19PPCh. 7 - The Social Security Administration maintains an...
Knowledge Booster
Similar questions
- Give an example from your own idea, of a program that use a void function (does not return avalue), based on your understanding. (You must include a main function)arrow_forwardC++ Write the definition of the function int computerProd() with parameters that receives as arguments two integer values values, computes their product and returns it to the calling function.arrow_forwardAssume that the declarations for two functions look as follows: int Function1(double x); 2.void Function2(double x); Give some sample code that would show how each function could be used.arrow_forward
- 1. Write a function which takes one parameter int num, and prints out a countdown timer with minutes and seconds separated by a colon (:). It should print out one line for each second elapsed and then pause one second before printing out the next line. A few things to note: - You can assume that calling the function usleep(1000000) makes the program pause for one second - It should count down from num minutes:zero seconds to zero minutes:zero seconds - Your function must have the following signature: void timer(int num) You do not need to demonstrate calling this function from main(). You don't need to format the output nicely; the below is acceptable output for calling this function when minutes is 10: 10:0 9:59 9:58 … 9:1 9:0 8:59 8:58 … 0:2 0:1 0:0arrow_forwardWrite a function declaration and a function definition for a function that takes one argument of type int and one argument of type double, and that returns a value of type double that is the average of the two arguments.arrow_forwardWrite a function checkeven which receives 3 integer variables and prints YES if all three numbers are even. Otherwise the function prints NO. ("receives" means that these values will be passed to the function as parameters) Write the statements to read in three numbers and call the checkeven function.arrow_forward
- Use Clojure to complete these questions: Please note that this is the beginning of the course so please use simple methods possible, thanks a. The built-in function type is useful for checking what kind of object an expression evaluates to. Write a function both-same-type? that takes two arguments, and returns true when they both have the same type, and false otherwise. b. Write a function list-longer-than? which takes two arguments: an integer n, and a list lst and returns true if lst has more than n elements, and false otherwise. For example, (list-longer-than? 3 '(1 2 3)) should return false, and (list-longer-than? 2 '(1 2 3)) should return true. c. See attached picture.arrow_forwardWrite a function example that takes two parameters and return one single parameter of same data type as output. Test that function in main function.arrow_forwardWrite a function definition for a function called even that takes one argumentof type int and returns a bool value. The function returns true if its oneargument is an even number; otherwise, it returns false.arrow_forward
- 9-Given the code segment below, what should be the data type of the formal parameter in the function prototype of func(), given the call from main()? Note that function prototypes need not include the identifier (name of the parameter), so do NOT put any variable name in your answer. Remove any space in your answer. If the accessing is wrong, answer INVALID (in all capital letters). void func( ______ ); int main() { double aData[6][4]; func(&aData[4]); return 0; }arrow_forwardCan we use a function as a parameter of another function? [Eg: void wow(int func())].a) Yes, and we can use the function value convenientlyb) Yes, but we call the function again to get the value, not as convenient as in using variablec) No, C does not support itd) This case is compiler dependentarrow_forwardCreate a program that accepts an integer N, and pass it to the function generatePattern. generatePattern() function which has the following description: Return type - void Parameter - integer n This function prints a right triangular pattern of letter 'T' based on the value of n. The top of the triangle starts with 1 and increments by one down on the next line until the integer n. For each row of in printing the right triangle, print "T" for n times. In the main function, call the generatePattern() function. Input 1. One line containing an integer Output Enter N: 4 T TT TTT TTTTarrow_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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning