Question
Book Icon
Chapter 7.2, Problem 12STE
Program Plan Intro

Purpose of given code:

The given code is initializes the array “b[]” and passes each value by calling the function “tripler()” using “for” loop.

Given code:

/*Function definition with argument*/

void tripler(int& n)

{

/*Calculation of "n" value*/

n=3*n;

}

/*Declaration and initialization of variable*/

int b[5]={1,2,3,4,5};

//Error

for(int i=1;i<=5;i++)

/*Call the function with argument value*/

tripler(b[i]);

Explanation of given code:

  • The code defines the function “tripler()” which takes the address of an argument.
    • The value of passed by argument is multiplied by “3” and stored into the variable “n”.
  • The array variable “b[]” was initialized in type of integer.
  • Using “for” loop, call the function with each value of array.

Blurred answer
Students have asked these similar questions
IN JAVA  intends to auto generate test cases for a function foo that has k integers as input arguments, i.e., foo(int n1, int n2, …, int nk). Each argument belongs to a different equivalence class, which are stored in a downloadable Eq.txt file. The content is shown below and may be modified to handle more inputs and equivalence classes.  1, 15; 16, 30 1, 10; 11, 20; 21, 30 1, 5; 6, 10; 11, 15 1, 3; 4, 6; 7, 9; 10, 12 1, 12; 13, 24 For this file, the nth row describes the nth input. Take the second row for example. There are five input arguments. The data 1, 10; 11, 20; 21, 30 indicates that argument n2 has three equivalence classes separated by the semi-colons. Develop an internal method “private int check(int val)” that returns the equivalence class the val is in. The result of check(val = 3) for n2 will be 1 and check(val = 25) for n2 will be 3. Regarding the function foo, it computes the sum of the returned values by the check function for all input arguments. Follow the contents…
pls give mommens by expression and statements , thanks Recall that in C++, there is no check on an array index out of bounds.  However, during program execution, and array index out of bounds can cause serious problems.  Also, in C++, the array index starts at zero. Design and implement the class myArray that solves the array index out of bounds problem, and also allows the user to begin the array index starting at any integer, positive or negative.  Every object of type myArray is an array of type int.  During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message.  Consider the following statements: myArray<int> list(5);               //Line 1 myArray<int> myList(2, 13);         //Line 2 myArray<int> yourList(-5, 9);       //Line 3   This statement in line one declares list to be an array of five components, the component type is int, and components are: list[0], list[1],…, list[4];…
WITE JAVA CODE JUST TO THE GIVEN CODE BELOW! TESTS GIVE ERROR FOR SHRINK AND add remove 100 values ALSO, DO IT BY CHECKING THE MAIN CLASS WITHOUT CHANGING IT class Queue<T> {  private T[] a = (T[]) new Object[1];  private int N = 0;  public boolean isEmpty() {    return N == 0;  }  public int size() {    return N;  }  private void resize(int capacity) {     T[] temp = (T[]) new Object[capacity];    for (int i = 0; i < N; i++) {      temp[i] = a[i];    }    a = temp;  }   public void enqueue(T item) {     if (N == a.length) resize(2*a.length);    a[N++] = item;  }  public T dequeue() {      T item = a[--N];    a[N] = null;    if (N > 0 && N == a.length/4) resize(a.length/2);    return item;  }   // this method is for unit testing; don't touch  public int getArraySize(){    return a.length;  }}   public class Main {   public static void main(String[] args)  {     Queue<Integer> myQueue = new Queue<Integer>();     int i;     i = 1;     myQueue.enqueue(i);…

Chapter 7 Solutions

Problem Solving with C++, Student Value Edition Plus MyLab Programming with Pearson eText - Access Card Package (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...
Knowledge Booster
Background pattern image
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