C++ for Engineers and Scientists
4th Edition
ISBN: 9781133187844
Author: Bronson, Gary J.
Publisher: Course Technology Ptr
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7.6, Problem 9E
(Practice) Use the max_element and min_element algorithms to determine the maximum and minimum values in the
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Question: (Related to R-language)-Looking answer to the below question.
"Given a numeric vector x of arbitrary length, write code to create a vector y that contains the squares of the values of x (note: x and y will have the same length). Your solution should not involve more than a couple of lines of code" .
Provide single line MATLAB:a) Create 1x6 vector called A containing integer values between from 15 to 10.b) Create 1x6 vector called B whose values are equal to 100 times in A.c) Create a vector called C that goes at equal steps from −20 to +20 containing 50elements.d) Create 3x6 matrix called D from A,B and C vectors by putting them on top of eachother. (Use first 6 elements of C).e) Create 20x3 matrix called E whose values row number (n), n squared (n2) and n cube(n3).
Problem 1) Find how many non-zero element are in a matrix (two-dimensional array)- use as
an example:
10
-4 0
8.
3
1
Read the values from input (scanf) using for loops and test your code one other set of values.
Problem 2) Extract diagonal elements of a square matrix and put into a column array.
As an example, you can read the matrix below from input using scanf:
10
22
-7
-9
21
60
8 5
And your output display should look like:
1
60
-7
Your code must use for loops. Test your code with a 4x4 size square matrix and your choice of
values.
Chapter 7 Solutions
C++ for Engineers and Scientists
Ch. 7.1 - (Practice) Write array declarations for the...Ch. 7.1 - (Practice) Write correct notation for the first,...Ch. 7.1 - Prob. 3ECh. 7.1 - (Practice) a. Write output statements using cout...Ch. 7.1 - (Desk check) List the elements displayed by the...Ch. 7.1 - (Practice) a. Write a program to input the...Ch. 7.1 - (Practice) Write a program to input eight integer...Ch. 7.1 - (Data processing) a. Write a program to input 10...Ch. 7.1 - Prob. 9ECh. 7.1 - (Electrical eng.) Write a program that specifies...
Ch. 7.2 - (Practice) Write array declarations, including...Ch. 7.2 - (Data processing) Write an array declaration...Ch. 7.2 - (Data processing) Write a program that uses an...Ch. 7.2 - (Electrical eng.) Write a program that stores the...Ch. 7.2 - (Practice) a. Write a declaration to store the...Ch. 7.3 - (Practice) Write specification statements for the...Ch. 7.3 - (Desk check) Determine the output produced by the...Ch. 7.3 - (Practice) a. Write a C++ program that adds the...Ch. 7.3 - (Practice) Write a C++ program that adds...Ch. 7.3 - Prob. 5ECh. 7.3 - (Electrical eng.) a. An engineer has constructed a...Ch. 7.4 - Prob. 1ECh. 7.4 - Prob. 2ECh. 7.4 - Prob. 3ECh. 7.4 - Prob. 4ECh. 7.4 - Prob. 5ECh. 7.4 - (Electrical eng.) Write a program that declares...Ch. 7.4 - (Statistics) Write a program that includes two...Ch. 7.5 - Prob. 1ECh. 7.5 - (Practice) Run Program 7.10 to determine the...Ch. 7.5 - Prob. 3ECh. 7.5 - (List maintenance) a. Write a complete C++ program...Ch. 7.5 - Prob. 5ECh. 7.5 - (List maintenance) The following letters are...Ch. 7.5 - (File creation) Write a C++ program that creates...Ch. 7.5 - Prob. 8ECh. 7.5 - Prob. 9ECh. 7.5 - Prob. 10ECh. 7.5 - Prob. 11ECh. 7.5 - Prob. 12ECh. 7.5 - Prob. 13ECh. 7.5 - Prob. 14ECh. 7.5 - Prob. 15ECh. 7.6 - Prob. 1ECh. 7.6 - Prob. 2ECh. 7.6 - Prob. 3ECh. 7.6 - Prob. 4ECh. 7.6 - Prob. 5ECh. 7.6 - Prob. 6ECh. 7.6 - Prob. 7ECh. 7.6 - Prob. 8ECh. 7.6 - (Practice) Use the max_element and min_element...Ch. 7 - (Statistics) a. Write a C++ program that reads a...Ch. 7 - (Practice) Define an array named peopleTypes that...Ch. 7 - (Numerical) Given a one-dimensional array of...Ch. 7 - (Numerical) Write and test a function that returns...Ch. 7 - (Sorting) Read a set of numerical grades from the...Ch. 7 - (Numerical) a. Define an array with a maximum of...Ch. 7 - (Numerical) Using the srand() and rand() C++...Ch. 7 - (Statistical) In many statistical analysis...Ch. 7 - (Data processing) Your professor has asked you to...Ch. 7 - (Modify) Modify the program written for Exercise 9...Ch. 7 - Prob. 11PPCh. 7 - (Data processing) The answers to a true-false test...Ch. 7 - Prob. 13PPCh. 7 - (Data processing) Construct a three-dimensional...Ch. 7 - (Computation) A magic square is a square of...Ch. 7 - (Computation) Among other applications, Pascal’s...
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
- Practice 3. Modify the above program (Practice 2) to compute the sum of two vectors (Ref: slide 43). aNTIS Output: Enter the array's elements Number enter the First elements Vector Element 1 Element 2 Element 3 enter she Second elements Vector lement 2 lement 3arrow_forward[Problem Description] write a program that reads a m-by-n (m,n<=10) matrix and the row number, find the largest element in a specific row [Input form] row number matrix elements [Output format] the largest element [Sample input] twenty three 2 12 56 47 [Example output] 6 [Example description] [Score criteria] Speaking:arrow_forwardProblem#1: MATLAB PROGRAM 1. Create a 5 by 3 array of random integer numbers ranged from 0 to -90, 2. Find how many numbers that are divisible by 11 in the array? And specify their locations and store them in a separate array 3. Find the location of maximum and the minimum number in the array 4. Create a structure that consist of four fields, {array, max, min, sum} File in these fields with : o The array in #1. o Max: contains the index and the value for the maximum number in the array in #1 o Min: contains the index and the value for the maximum number in the array in #1 o Sum: the summation of the items inside the array in #1arrow_forward
- c program question:Write a program to add elements of two 3x3 matrices and store it in third 3x3 matrix. Algorithm: 1-Read elements for Matrix A (3x3 Matrix). 2- Read elements for Matrix B (3x3 Matrix).3- Add elements of each matrix and store it in Matrix C (3x3 Matrix). 4-Display the elements of the Third Matrix Do the same procedure as that of Exercise 2.1. Input: Matrix A Input: Matrix B Output: Matrix Carrow_forwardQuestion 58 The MATLAB function roots is used in the following statement: p= roots(x) Identify the correct statement(s) regarding p and x. (Select all that apply.) O x is a vector containing the roots of a polynomial. O p is a vector containing the roots of a polynomial. O p is a vector containing the coefficients of a polynomial. x is a vector containing the coefficients of a polynomial.arrow_forwardPython problem Problem statementCalculate the dot product or dot product of two vectors. Link for more information on the scalar product. To calculate the dot product it is necessary that the two vectors have the same size, otherwise an error would occur. EntryTwo lines containing the vectors or list of numbers. Each line has the vector values separated by space. All numbers comply with -1000 <= n <= 1000 DeparturePrints a real number rounded to 2 decimal places corresponding to the dot product of the two vectors. If the size of the vectors does not correspond, “Error” should be printed without quotes. Examples Input Example 1 3.0 3.2 1.2 3.0 1.01.2 3.5 3.1 4.9 1.0Output Example 1 34.22 Input Example 2 1 2 3 41 2 3Output Example 2 Errorarrow_forward
- Problem 4 Using two-dimensional arrays, write a program which multiplies an axb matrix of integers by a exd matrix of integers. Ask the user to enter a value for first matrix and second matrix. The multiple the matrix. (Hint: discrete structure class)arrow_forwardCourse : Formal Methods in Software Engineering Q. In a simple searching program the function returns a key value when found inside an array. Specify the Post-Conditions when the key is found and when the key is not found. Write the specification in an expression format.arrow_forward(A) You need to create two passwords to a system; both these passwords are stored in a string matrix 5x5. The first password is stored in the first element of the matrix, and the second password is stored in the third element of the matrix. Write a program that asks the user to enter a password (string) which must match with one of the two passwords of the system. Note the user can re-enter the password four times if it is not correct.arrow_forward
- Answer in C++ code please! (Duplicate Elimination with vector) Use a vector to solve the following problem. Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, validate it and store it in the vector only if it isn't a duplicate of a number already read. After reading all the values, display only the unique values that the user entered. Begin with an empty vector and use its push_back function to add each unique value to the vector.arrow_forwardI'm broke :((( Create a python program a. Create a user-defined array for any size n determined/chosen by the use b. Write a function that displays all prime numbers of the elements of an array and then returns all primes as a single array. Call this function to find all the prime numbers from the array in item 1a. c. Write another function that solves for the average of the elements of an array. Call this function to find the average of all prime numbers in item 1b. d. Write another function that determines the perfect squares in an array. Display the result as an ordered pair (u, v) where u is a perfect square and v is its corresponding square root. Callthis function to find all perfect squares of the array in item 1a.arrow_forwardProgram 2: (LAB 7) Write a program for printing the largest elements in each row of an array using function. The function should take an array. and number of rows and columns as parameterarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
CPP Function Parameters | Returning Values from Functions | C++ Video Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=WqukJuBnLQU;License: Standard YouTube License, CC-BY