Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 7, Problem 2P

Write a function named countNum2s that takes as input an array of integers and an integer that specifies how many entries are in the array. The function should return the number of 2’s in the array. Test your function with arrays of different length and with varying number of 2’s.

Blurred answer
Students have asked these similar questions
Write a program that creates a two-dimensional array initialized with test data. Use any data type you wish. The program should have the following functions:a. getTotal . This function should accept a two-dimensional array as its argument and return the total of all the values in the array.b. getAverage . This function should accept a two-dimensional array as its argument and return the average of all the values in the array.c. getRowTotal . This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row.d. getColumnTotal . This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The function should return the total of the values in the specified column.e. getHighestInRow .…
Write a function named swapFrontback that takes as input an array ofintegers and an integer that specifies how many entries are in the array. Thefunction should swap the first element in the array with the last elements inthe array. The function should check if the array is empty to prevent errors.The header file for the swapFrontback() is:swapFrontback.h:double swapFrontback (int [] arr,int size);Write a driver (main.c) to test your function with arrays of different lengthand with varrying front and back numbers. Print the array elements beforeand after the swap in the main.c.Sample Run: Original Array: 1 2 3 4 5 6 FrontBack Array: 6 2 3 4 5 1
Write a program that creates a 2D array of integers of size nXn initialized with test data.The program should have the following functions:● getTotal. This function should accept a 2D array as an argument and returnthe total of all the values in the array.● getAverage. This function should accept a 2D array as an argument and returnthe average of all the values in the array.● getRowTotal. This function should accept a 2D array as the first argument andan integer as its second argument. The second argument should be the subscriptof a row in the array. The function should return the total of the values in thespecified row.● getColumnTotal. This function should accept a 2D array as the first argumentand an integer as its second argument. The second argument should be thesubscript of a column in the array. The function should return the total of thevalues in the specified column.● getHighestInRow. This function should accept a 2D array as the firstargument and an integer as its second…

Chapter 7 Solutions

Problem Solving with C++ (10th Edition)

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...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License