Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
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
How we can pass the function pointer as a parameter give example.
Find any errors in the following function declarations:
void sun(void, void);
Define stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name)"
followed by a newline, and should return -1. Each stub must also contain the function's parameters.
Sample output with two calls to get_user_num() and one call to compute_avg():
FIXME: Finish get_user_num()
|
FIXME: Finish get_user_num()
FIXME: Finish compute_avg()
Avg: -1
354684.2266598.qx3zgy7
2
Your solution goes here '''
4 user_num1
5 user_num2
6 avg_result
get_user_num()
get_user_num)
compute_avg(user_num1, user_num2)
8 user_num1
9 user_num2
10 avg_result
%3D
11
12 print('Avg:', avg_result)
Chapter 7 Solutions
Problem Solving with C++ (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
- float ACM (void); is non-void function with no parameters Select one: O True O Falsearrow_forwardWrite a declaration for a function called test( ) that takes 2 arguments and returns type char. The first argument is type int and the second is type float with a default value of 5arrow_forwardWrite a void function called 'qualify' that prints the message 'You qualify for the bonus' . Write the prototype for your function. Write a call for your functionarrow_forward
- Playing with Functions: Write a Javascript program to check if the argument passed to any function is a function type or not. I.e. Create a function check which takes a argument and check if that argument is a function or not.arrow_forward6. Write a void function, called "intDiv", that takes two integers n and m, and returns as reference parameters the factor (how many times m goes to n) and modulus (remainder n%m) without using the C++ operators for division (/) and modulus (8). Γράψτε μια void συνάρτη η, που ονομάζεται "intDiv", που παίρνει δύο ακέραιους αριθμούς η και m , και επιστρέφει ως παραμέτρους αναφοράς τον παράγοντα (πόσες φορές το m πηγαίνει στο n) και το υπόλοιπο (n% m ) χωρίς τη χρήση των τελεστν C++ για διαίρεση ( /) και υπόλοιπο (%). For example, if n = 13 and m= 5, then factor = 2 and modulus = 3. Hint: use repeated additions / subtractions. χρησιμοποιή στε επαναλαμβανό μενες προσθήκες / αφαιρέσεις .arrow_forwardWrite the definition of a void function that takes as input two parameters of type int, say sum and testScore the function updates the value of sum by adding the value of testScore. The new value of sum is reflected in the calling environment.arrow_forward
- Create 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_forwardTrue or false? A call to a function with a void return type is always a statement itself, but a call to a value-returning function cannot be a statement by itself.arrow_forwardWrite a function called area circumference generator that takes a radius of a circle as a function parameter and calculates its circumference and area. Then returns these two results as a tuple and prints the results using tuple unpacking in the function call accorrding to the given format. [Must use tuple packing & unpacking] Example1: Function Call: area_circumference_generator(1) Output: (3.141592653589793, 6.283185307179586) Area of the circle is 3.141592653589793 and circumference is 6.283185307179586 ======== :===== Example2: Function Call: area_circumference_generator(1.5) Output: (7.0685834705770345, 9.42477796076938) Area of the circle is 7.0685834705770345 and circumference is 9.42477796076938arrow_forward
- Define stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name()" followed by a newline, and should return -1. Each stub must also contain the function's parameters.Sample output with two calls to get_user_num() and one call to compute_avg(): FIXME: Finish get_user_num() FIXME: Finish get_user_num() FIXME: Finish compute_avg() Avg: -1 ''' Your solution goes here ''' user_num1 = 0user_num2 = 0avg_result = 0 user_num1 = get_user_num()user_num2 = get_user_num()avg_result = compute_avg(user_num1, user_num2) print('Avg:', avg_result)arrow_forwardDefine stubs for the functions get_user_num() and compute_avg(). Each stub should print "FIXME: Finish function_name()" followed by a newline, and should return -1. Each stub must also contain the function's parameters. Sample output with two calls to get_user_num() and one call to compute_avg(): FIXME: Finish get_user_num( ) FIXME: Finish get_user_num() FIXME: Finish compute_avg() Avg: -1 Learn how our autograder works 461710.3116374.qx3zqy7 1234 3 111 Your solution goes here ** 4 user_num1 = 0 5 user_num2 = 0 6 avg_result = 0 7 8 user_num1 = get_user_num() 9 user_num2 = get_user_num() 10 avg_result = compute_avg(user_num1, user_num2) 11 12 print (f'Avg: {avg_result}')arrow_forwardWrite the function prototype of the void function named G() that takes an int reference parameter and two char parameters respectively Your answerarrow_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