MyLab Programming with Pearson eText -- Standalone Access Card -- for Starting Out With C++: Early Objects (My Programming Lab)
9th Edition
ISBN: 9780134379548
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8.12, Problem 8.29CP
Define gators to be an empty
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What to input here to run properly?
%Encode A1, b1 and x1 as the vector of unknowns.
A1 =
b1 =
syms
xv1 =
%Check the size of A, set it as m1 and n1
[m1,n1] =
%Augment A and b to form AM1
AM1 =
%Solve the Reduced Rwo Echelon of AM1.
RREFA1 =
%Collect the last column and set as bnew1, set the remaining elements as Anew1
bnew1=
Anew1 =
%Check if Anew is an identity matrix, if it is, bnew is the solution
if Anew1 =eye(m1,n1)
Root1 = bnew1
else
display("No Solution")
end
%Augment the matrix A1 with the identity Matrix of the same size, set the result as AMI1
AMI1 =
%Find the reduced row echelon form of AMI1, set the result as RREFAI1
RREFAI1=
%Collect the second half of the matrix as AInew1, set the remaining elements as AIold1
AInew1=
AIold1 =
%Check if AIold1 is an identity matrix, if it is, AInew1 is the inverse
%Encode A2, b2 and xv2 as the vector of unknowns.
A2 =
b2 =
syms
xv2 =
%Check the size of A2, set it as m2 and n2
[m2,n2] =
%Augment…
Write a function named cumulative that accepts as a parameter a reference to a vectorof integers, and modifies it so that each element contains the cumulative sum of the elements up through that index. For example, if the vector passed contains {1, 1, 2, 3, 5}, your function should modify it to store {1, 2, 4, 7, 12}.
Use a range-based for loop in C++ to loop through a given vector of integers and determine how many elements in the vector are evenly divisible by either 3 or by 5.
The final result should be stored in an integer variable named count.
Use the following vector vec of integers (hardcoded) in your program.
vector<int> vec {1,3,5,15,16,17,18,19,20,21,25,26,27,30,50,55,56,58,100,200,300,400,500,600,700};
Output: First display the integers that are evenly divisible by 3 or 5, then display the count.
Chapter 8 Solutions
MyLab Programming with Pearson eText -- Standalone Access Card -- for Starting Out With C++: Early Objects (My Programming Lab)
Ch. 8.3 - Define the following arrays: A) empNum, a 100...Ch. 8.3 - Prob. 8.2CPCh. 8.3 - Prob. 8.3CPCh. 8.3 - Assume a program includes the following two...Ch. 8.3 - What is array bounds checking? Does C++ perform...Ch. 8.3 - What is the output of the following code? int...Ch. 8.3 - Complete the following program skeleton so it will...Ch. 8.7 - Define the following arrays: A) ages, a 10-element...Ch. 8.7 - Indicate if each of the following array...Ch. 8.7 - Prob. 8.10CP
Ch. 8.7 - Given the following array definition: int values...Ch. 8.7 - Prob. 8.12CPCh. 8.7 - Prob. 8.13CPCh. 8.7 - What is the output of the following code? const...Ch. 8.9 - Write a typedef statement that makes the name...Ch. 8.9 - Prob. 8.16CPCh. 8.9 - What is the output of the following program...Ch. 8.9 - The following program segments, when completed,...Ch. 8.11 - Prob. 8.19CPCh. 8.11 - Prob. 8.20CPCh. 8.11 - Prob. 8.21CPCh. 8.11 - Prob. 8.22CPCh. 8.11 - Prob. 8.23CPCh. 8.11 - Fill in the empty table below so it shows the...Ch. 8.11 - Write a function called displayArray7. The...Ch. 8.11 - Prob. 8.26CPCh. 8.12 - Prob. 8.27CPCh. 8.12 - Write definition statements for the following...Ch. 8.12 - Define gators to be an empty vector of ints and...Ch. 8.13 - True or false: The default constructor is the only...Ch. 8.13 - True or false: All elements in an array of objects...Ch. 8.13 - What will the following program display on the...Ch. 8.13 - Complete the following program so that it defines...Ch. 8.13 - Add two constructors to the Product structure...Ch. 8.13 - Prob. 8.35CPCh. 8.13 - Prob. 8.36CPCh. 8.13 - Prob. 8.37CPCh. 8.13 - Write the definition for an array of five Product...Ch. 8.13 - Write a structure declaration called Measurement...Ch. 8.13 - Write a structure declaration called Destination ,...Ch. 8.13 - Define an array of 20 Destination structures (see...Ch. 8 - The ________ indicates the number of elements, or...Ch. 8 - The size declarator must be a(n) _______ with a...Ch. 8 - Prob. 3RQECh. 8 - Prob. 4RQECh. 8 - The number inside the brackets of an array...Ch. 8 - C++ has no array ________ checking, which means...Ch. 8 - Prob. 7RQECh. 8 - If a numeric array is partially initialized, the...Ch. 8 - If the size declarator of an array definition is...Ch. 8 - Prob. 10RQECh. 8 - Prob. 11RQECh. 8 - Prob. 12RQECh. 8 - Arrays are never passed to functions by _______...Ch. 8 - To pass an array to a function, pass the ________...Ch. 8 - A(n) ________ array is like several arrays of the...Ch. 8 - Its best to think of a two -dimensional array as...Ch. 8 - Prob. 17RQECh. 8 - Prob. 18RQECh. 8 - When a two -dimensional array is passed to a...Ch. 8 - When you pass the name of an array as an argument...Ch. 8 - Look at the following array definition. int values...Ch. 8 - Given the following array definition: int values...Ch. 8 - Prob. 23RQECh. 8 - Assume that array1 and array2 are both 25-element...Ch. 8 - Prob. 25RQECh. 8 - How do you establish a parallel relationship...Ch. 8 - Look at the following array definition. double...Ch. 8 - Prob. 28RQECh. 8 - Prob. 29RQECh. 8 - Prob. 30RQECh. 8 - Prob. 31RQECh. 8 - The following code totals the values in each of...Ch. 8 - Prob. 33RQECh. 8 - Prob. 34RQECh. 8 - In a program you need to store the identification...Ch. 8 - Prob. 36RQECh. 8 - Prob. 37RQECh. 8 - Prob. 38RQECh. 8 - Each of the following functions contains errors....Ch. 8 - Soft Skills Diagrams are an important means of...Ch. 8 - Perfect Scores 1. Write a modular program that...Ch. 8 - Larger Than n Create a program with a function...Ch. 8 - Roman Numeral Converter Write a program that...Ch. 8 - Chips and Salsa Write a program that lets a maker...Ch. 8 - Monkey Business A local zoo wants to keep track of...Ch. 8 - Rain or Shine An amateur meteorologist wants to...Ch. 8 - Lottery Write a program that simulates a lottery....Ch. 8 - Rainfall Statistics Write a modular program that...Ch. 8 - Lo Shu Magic Square The Lo Shu Magic Square is a...Ch. 8 - Baseball Champions This challenge uses two files...Ch. 8 - Chips and Salsa Version 2 Revise Programming...Ch. 8 - Stats Class and Rainfall Statistics Create a Stats...Ch. 8 - Stats Class and Track Statistics Write a client...Ch. 8 - Prob. 14PCCh. 8 - Drivers License Exam The State Department of Motor...Ch. 8 - Array of Payro11 Objects Design a PayRoll class...Ch. 8 - Drink Machine Simulator Create a class that...Ch. 8 - Bin Manager Class Design and write an object...Ch. 8 - Tic-Tac-Toe Game Write a modular program that...Ch. 8 - Theater Ticket Sales Create a TicketManager class...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What Ada construct provides support for abstract data types?
Concepts Of Programming Languages
Describe the difference between the while loop and the do-while loop.
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Given that y=ax3+7, which of the following are correct Java statements for this equations? int y = a x x x +...
Java How To Program (Early Objects)
Enhance the definition of the class StringVar given in Displays 11.11 and 11.12by adding all of the following: ...
Problem Solving with C++ (10th Edition)
This operator performs division, but instead of returning the quotient it returns the remainder. a. % b. c. d...
Starting Out with Python (3rd Edition)
What is the output of the following program? #include iostream using namespace std; void test(int = 2, int = 4,...
Starting Out with C++ from Control Structures to Objects (8th Edition)
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
- Implement the following function without using any additional data structure, and without sorting the input vectors. /* Given two vectors of integers, check if the two vectors contain same set of values: e.g., V1=[3,4,10,4,10,11] and V2=[3,3,4, 11, 10] stores same set int: {3, 4, 10, 11}. Note that duplicates are removed when considering set */ @param list1, list2: two vectors of integers@pre: list1, list2 have been initialized@post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */ bool SameSet (const vector<int> & list1, const vector<int> & list2) {//for each value in list1, check if it appears in list2, if not, return false //for each value in list2, check if the value appears in list1, if not return false //return true}arrow_forwardImplement the following function, without using any data structure. /* Given two vectors of chars, check if the two vectors are permutations of each other, i.e., they contains same values, in same or different order.e.g., V1=[‘a’,’b’,’a’] and V2=[‘b’,’a’,’a’] stores same multi-set of data points: i.e., both contains two ‘a’, and one ‘b’. e.g., V3=[‘a’,’c’,’t’,’a’] and V4=[‘a’,’c’,’t’] are not same multi-set. V3 contains two ‘a’s, while V4 has only one ‘a’. Note: when considering multiset, the number of occurrences matters. @param list1, list2: two vectors of chars @pre: list1, list2 have been initialized @post: return true if list1 and list2 stores same values (in same or different order); return false, if not. */ bool SameMultiSet (vector<char> list1, vector<char> list2)arrow_forwardProgram in C. Write a function that receives a vector of integers already sorted in ascending order, an integer n representing the number of elements in this vector, and an integer b. Implement the sequential search algorithm to look for the integer b in the vector. The binary search works as follows: you must look for the element in the position exactly in the half of the vector, if it is the searched one, it returns the number of tests done so far, if it is not the searched one, calculate the midpoint of the half of the vector after assess whether the searched value is greater or less than the value at the middle position. Not finding the value searched, the function must return 0. The name of the function will be called "busca_bin". int bin_search(int array[], int n, int b){//code}arrow_forward
- Code in C. Solve the code below. write a function that receives a vector of integers already sorted in ascending order, an integer n represents the number of elements in this vector, and an integer b. Implement the sequential search algorithm to look for the integer b in the vector. The binary search works as follows: you must look for the element in the position exactly in the half of the vector, if for the searched it returns the number of tests done so far, if not for the searched, calculate the midpoint of the half of the vector after assess whether the searched value is greater or less than the value at the middle position. Not finding the value searched, the function must return 0. The name of the function will be called "busca_bin". int busca_bin (int vetor [ ], int n, int b){ #include <stdio.h> int busca_bin(int vetor[] , int n , int a) { int s1 = 0; int s2 = n-1; int pass = 0; int s3; while(s1<s2) { s3 = (s1+s2)/2; pass++;…arrow_forwardCode in C. Solve the code below. write a function that receives a vector of integers already sorted in ascending order, an integer n represents the number of elements in this vector, and an integer b. Implement the sequential search algorithm to look for the integer b in the vector. The binary search works as follows: you must look for the element in the position exactly in the half of the vector, if for the searched it returns the number of tests done so far, if not for the searched, calculate the midpoint of the half of the vector after assess whether the searched value is greater or less than the value at the middle position. Not finding the value searched, the function must return 0. The name of the function will be called "busca_bin". int busca_bin (int vetor [ ], int n, int b){// your code} My code #include <stdio.h> int busca_bin(int vetor[] , int n , int a) { int s1 = 0; int s2 = n-1; int pass = 0; int s3; while(s1<s2) {…arrow_forwardC++ please help I will give you a good rating!!!!! Implement the following function that returns a vector of vectors of Item, each of which is a subset of elements chosen from the given vector a[first…last]: /* if a is {1,2,3}, first=0, last=2, the function shall returns a vector of the following vectors: {}, {1}, {2}, {3}, {1,2},{1,3}, {2,3},{1,2,3}, all subsets of a[0…2]. Precondition: last-first+1>=1, i.e., there is at least one element in the a[first…last] Note 1)if the length of a[first…last] is n, then the function should return a vector of 2n vectors 2) The order of these subsets does not need to match what’s listed here… */ vector<vector<int>> subsets (const vector<int> & a, int first, int last) CODE: #include <iostream> #include <algorithm> #include <vector> using namespace std; void PrintVector (const vector<int> & v){ cout <<"["; for (auto e:v){ cout<<e<<" "; } cout <<"]"; } /*…arrow_forward
- Create a function set(v, i, j) that makes vector v contain the integers i through j. The original contents of v is deleted. The vector is left empty ifj < i. The argument v is a vector of integers.arrow_forwardWrite a function named addStars that accepts as a parameter a reference to a vector of strings, and modifies the vector by placing a "*" element between elements, as well as at the start and end of the vector. For example, if the vector v contains {"the", "quick", "brown", "fox"}, the call of addStars(v); should modify it to store {"*", "the", "*", "quick", "*", "brown", "*", "fox", "*"}.arrow_forwardWrite a complete program that will do the following in C++ a.Declare an integer vector without specifying any size. b.Insert the values 5,10,15, 8, 4 into the vector c.Multiply the elements of vector using a for loop. d.Print the product of all the elements of the vector.arrow_forward
- Write a function that receives a vector of integers already sorted in ascending order, an integer n representing the number of elements in this vector, and an integer b. Implement the sequential search algorithm to look for the integer b in the vector. The binary search works as follows: you must look for the element in the position exactly in the half of the vector, if it is the one searched for it returns the number of tests done so far, if it is not the searched one, calculate the midpoint of the half of the vector after assess whether the searched value is greater or less than the value at the middle position. Not finding the value searched, the function must return 0. The name of the function will be called "busca_bin". Program in C.arrow_forwardWrite a function called genericSort() that takes in a numeric or integer vector, sorts it, and returns the indices of the sorted values. It should also print an error if the input is a character. For example, genericSort(c(1,3,7,5)) should return the vector (1,2,4,3). Programming in Rarrow_forwardProgram in C. Write a function that takes a vector of integers, an integer n representing the number of elements in that vector, and an integer b. Implement the sequential search algorithm to look for the integer b in the vector. The sequential search works as follows: you must look at all the elements of the vector until you find the b, from the first to the last. The function must return an integer representing how many elements the function tested until it found b. If it does not find the function, it must return 0. The name of the function must be called "search_seq". int search_seq(int array[], int n, int b){//code}arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
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