Concept explainers
A)
The Standard Template Library (STL) includes the collection of data types and
- A special data type called vector is offered by STL which is useful for standard arrays.
A vector stores the elements or values in sequence order and the values are stored in continuous memory locations.
- The subscript operator “[]” in the vector helps to read the content of each element.
- If there is a need of vector to be used in the programs, then the following header file must be used:
// Header file for vector
#include<vector>
After including the header file, then it is easy to initialize the vector object.
“#include vector” header file must be included to define the vector in a
Syntax:
Syntax to define a vector is as follows:
//syntax for declaring a vector with size
vector <data_type> name_of_vector(no_of_elements);
In the above line,
- The keyword “vector” represents the vector declaration.
- The “<data_type>” represents the type of data the vector can hold; the data types such as “int”, “float”, “string”, “char”, and “double”.
- The “name_of_vector” represents the name of the vector.
- The “no_of_elements” inside the brackets refers the number of elements that the vector can hold.
B)
Vector:
The Standard Template Library (STL) includes the collection of data types and algorithms which can be used by the programmer in their programs.
- A special data type called vector is offered by STL which is useful for standard arrays.
A vector stores the elements or values in sequence order and the values are stored in continuous memory locations.
- The subscript operator “[]” in the vector helps to read the content of each element.
- If there is a need of vector to be used in the programs, then the following header file must be used:
// Header file for vector
#include<vector>
After including the header file, then it is easy to initialize the vector object.
“#include vector” header file must be included to define the vector in a program.
Syntax:
Syntax to define a vector is as follows:
//syntax for declaring a vector with size
vector <data_type> name_of_vector(no_of_elements);
In the above line,
- The keyword “vector” represents the vector declaration.
- The “<data_type>” represents the type of data the vector can hold; the data types such as “int”, “float”, “string”, “char”, and “double”.
- The “name_of_vector” represents the name of the vector.
- The “no_of_elements” inside the brackets refers the number of elements that the vector can hold.
C)
Vector:
The Standard Template Library (STL) includes the collection of data types and algorithms which can be used by the programmer in their programs.
- A special data type called vector is offered by STL which is useful for standard arrays.
A vector stores the elements or values in sequence order and the values are stored in continuous memory locations.
- The subscript operator “[]” in the vector helps to read the content of each element.
- If there is a need of vector to be used in the programs, then the following header file must be used:
// Header file for vector
#include<vector>
After including the header file, then it is easy to initialize the vector object.
“#include vector” header file must be included to define the vector in a program.
Syntax:
Syntax to define a vector is as follows:
//syntax for declaring a vector with size
vector <data_type> name_of_vector(no_of_elements);
In the above line,
- The keyword “vector” represents the vector declaration.
- The “<data_type>” represents the type of data the vector can hold; the data types such as “int”, “float”, “string”, “char”, and “double”.
- The “name_of_vector” represents the name of the vector.
- The “no_of_elements” inside the brackets refers the number of elements that the vector can hold.
D)
Vector:
The Standard Template Library (STL) includes the collection of data types and algorithms which can be used by the programmer in their programs.
- A special data type called vector is offered by STL which is useful for standard arrays.
A vector stores the elements or values in sequence order and the values are stored in continuous memory locations.
- The subscript operator “[]” in the vector helps to read the content of each element.
- If there is a need of vector to be used in the programs, then the following header file must be used:
// Header file for vector
#include<vector>
After including the header file, then it is easy to initialize the vector object.
“#include vector” header file must be included to define the vector in a program.
Syntax:
Syntax to define a vector is as follows:
//syntax for declaring a vector with size
vector <data_type> name_of_vector(no_of_elements);
In the above line,
- The keyword “vector” represents the vector declaration.
- The “<data_type>” represents the type of data the vector can hold; the data types such as “int”, “float”, “string”, “char”, and “double”.
- The “name_of_vector” represents the name of the vector.
- The “no_of_elements” inside the brackets refers the number of elements that the vector can hold.
E)
Vector:
The Standard Template Library (STL) includes the collection of data types and algorithms which can be used by the programmer in their programs.
- A special data type called vector is offered by STL which is useful for standard arrays.
A vector stores the elements or values in sequence order and the values are stored in continuous memory locations.
- The subscript operator “[]” in the vector helps to read the content of each element.
- If there is a need of vector to be used in the programs, then the following header file must be used:
// Header file for vector
#include<vector>
After including the header file, then it is easy to initialize the vector object.
“#include vector” header file must be included to define the vector in a program.
Syntax:
Syntax to define a vector is as follows:
//syntax for declaring a vector with size
vector <data_type> name_of_vector(no_of_elements);
In the above line,
- The keyword “vector” represents the vector declaration.
- The “<data_type>” represents the type of data the vector can hold; the data types such as “int”, “float”, “string”, “char”, and “double”.
- The “name_of_vector” represents the name of the vector.
- The “no_of_elements” inside the brackets refers the number of elements that the vector can hold.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Starting Out With C++: Early Objects (10th Edition)
- Q1. The circle has two data members, a Point representing the center of the circle and a float value representing the radius as shown below. typedef struct{ Point center; float radius;} Circle; typedef struct{ int x; int y;}Point; Implement the following functions:a. float distance (Line l1);- computes and returns the distance between the two points of the line.distance = sqrt((x2-x1)^2+(y2-y1)^2) b. float diameter(Circle circ);- computes the diameter of a circle.. .arrow_forwardComplete the code.arrow_forwardC++arrow_forward
- 1. Define a struct for a soccer player that stores their name, jersey number, and total points scored. 2. Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the average number of points scored by the players.3. Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the index of the player who scored the most points.4. Write a Circle class that has the following member variables:• radius : a double• pi : a double initialized with the value 3.14159The class should have the following member functions:• Default Constructor. A default constructor that sets radius to 0.0.• Constructor. Accepts the radius of the circle as an argument.• setRadius. A mutator function for the radius variable.• getRadius. An accessor function for the radius variable.• getArea. Returns the area of the circle, which is calculated as area = pi * radius * radius• getCircumference. Returns…arrow_forwardDimensionary Investigation Code in C languagearrow_forward3. Use two vectors and make them into one. Use the following vectors:Vector#1 {1, 1, 5, -3, 0}Vector#2 {9,7,2}Return a vector containing 1, 1, 5, -3, 0, 9, 7, 2 (in that order)arrow_forward
- in c++ language pleasssearrow_forwardWhat does the function f do? struct Point2D { double x; double y; struct Triangle { Point2D v1; Point2D v2; Point2D v3; }; void f(Triangle&t) { } int temp = 12.5; temp = t.v1.x; t.v1.x = t.v1.y; t.v1.y = temp; } int main () { Triangle mytri; mytri.v1.x = 1.0; mytri.v1.y = 22.5; f (mytri); Swaps values of x and y in vertex 1 of an argument of type Triangle Initializes value of x in vertex 1 of an argument of type Triangle Sets all x,y values in all vertices of an argument of type Triangle Swaps value of x in vertex 1 with value of x in vertex 2, for an argument of typearrow_forwardنقطة واحدة Let A = {a; b; c; d} and R= {(a; a); (b; c); (c; b); (d; d)} then R is Transitive Equivalent not transitivearrow_forward
- For this c++ write a code for Parallel Arrays First, you have to define several arrays in your main program: employee names for each employee hourly pay rate for each employee total hours worked for each employee gross pay for each employee code format: // TODO: Add function prototypes for all the declared functions // TODO: Declare two functions to compute the highestPay and lowestPay// HINT: Each should return the index of the correct value in the grossPay array. /* TODO: Create a function called getEmployeeNamesArguments :Name array(first and last name)Maximum sizeReturn the number of names filled.*/ /* TODO: Create a function calledgetHourlyPayArguments :NameArray(filled in Step 1)HourlyPayArray(starts empty)NumberOfNamesFilled(from Step1)*/ int main(){// TODO: Declare an array of strings for the employeeNames able to hold a maximum of SIZE employees// TODO: Declare arrays of double hourlyPay and grossPay, each able to hold a maximum of SIZE employees // TODO: Declare a 2-D…arrow_forwardwrite a code in C++ You work for a streaming analytics company and have been tasked with writing a program that analyzes views and likes on a series of YouTube videos. Code a modular program that uses parallel arrays to store views, likes, and like percentages for a series of videos. The program must do the following: The program must first ask the user for the number of videos that will be selected from YouTube. This must be done using a function that is called. For each video, the program must use random numbers to generate the number of views, likes, and the like percentage and store each value in a series of parallel arrays. These arrays must NOT be declared globally. These arrays also must be populated using a loop that calls a series of functions to generate the views, likes, and like percentage. The following arrays must be declared: views[] - an array of type long to hold the randomly generated views each YouTube video gets likes[] - an array of type long to hold the…arrow_forwardIn the expression : D + E = F where D, E, and are vectors. F is the ______ of vectors D and E.arrow_forward
- 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