1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GrogVix [38]
3 years ago
5

Now, extend your test program by adding a second function named split that will identify all the individual values in a comma se

parated value string and return them in an array of string objects: int split(string str, string a[], int max_size); Your function will take three arguments: a comma separated value string str, an array a of string objects, and the maximum size of the array. You must use the nextString function from Stretch Problem (1) to obtain each value in the string and store it in the array starting, with the first element. Return the total number of values stored in the array. For example: string varray[VALUES]; 2 int cnt

Computers and Technology
1 answer:
otez555 [7]3 years ago
7 0

Answer:

The code to copy is :

#include <iostream>

#include <string>

using namespace std;

string nextString(string str, int start_index);

int split(string str, string a[], int max_size);

int main()

{

const int VALUES = 20;

string somestring;

string varray[VALUES];

//Prompt the user to enter a comma separated string

cout << "Enter a comma seperated string: ";

//read the string

getline(cin, somestring);

//call split() method on the given string and

//store the count of individual strings in cnt

int cnt = split(somestring, varray, VALUES);

//Print the individual strings

for (int i = 0; i<cnt; i++)

cout << varray[i] << endl;

return 0;

}

//returns a sub string that starts at strat_index

//in the given string and ends before a comma

string nextString(string str, int start_index)

{

int i;

//find a comma or end of the string, after strat_index

for (i = start_index;i < str.length();i++)

{

//if comma is found, exit the loop

if (str.at(i) == ',')

break;

}

//extract the sub string

string out= str.substr(start_index, i-start_index);

return out;

}

//splits the comma separted string as individual strings

//and returns the number of individual strings

int split(string str, string a[], int max_size)

{

int i, j;

int start_index = 0;

//search for commas in the given string

for (i = 0,j=0;i < str.length();i++)

{

//if comma is identified or end of the string is identified

//, then get a strig that starts at start_index using next string

if (str.at(i) == ',' ||i==str.length()-1)

{

//save each string into an array of strings

a[j] = nextString(str, start_index);

//update the next string starting postion(starts after comma)

start_index = i + 1;

j++;

}

}

return j;

Explanation:

Please see attachments

You might be interested in
Information in​ folders, messages,​ memos, proposals,​ emails, graphics, electronic slide​ presentations, and even videos create
valkas [14]

Answer:

The answer is "Unstructured"

Explanation:

In comparison, unstructured information applies to information, which doesn't suit the conventional column and rows concerning databases properly. It is also known as sources, that include mails, audio and video files, web pages and posts in  communication networks.

  • This tracks and communicates on travel and object flow-through sensors and much more.
  • These types of data are used in both companies and organizations.
5 0
3 years ago
Edhesive 6.8 lesson practice answers
FromTheMoon [43]

Answer:

1.) 25 ; 15 ; 15

2.) 50 ; 15 ; 50

Explanation:

In the first function written :

The variable val was initially decaled or assigned a value of 25 and that was what was printed first.

However, after the example function was written, the val variable was finally assiagned a value of 15 within the function. However, it was also declared that the global variable takes uonthe val value. Hence, the val variable initially assigned a value, of 25 changes to 15 globally.

For the second code :

From the top:

Val was assigned a value of 50 ;

Hence,

print(val) gives an output of 50

Within the function definition which prints the value of val that is assigned a value of 25 within the function.

Since tbe global variable isnt reset.

Printing Val again outputs 50;since ito is outside the function.

6 0
2 years ago
Write the document type declaration markup statement for an HTML5 file. Be sure to include the appropriate opening and closing b
GREYUIT [131]

Answer:

<!DOCTYPE html>

Explanation:

<!DOCTYPE html> is used in the HTML5. It is the document type declaration markup statement for an HTML5 file.

4 0
2 years ago
10 POINTS
Sunny_sXe [5.5K]

Answer:

True

Explanation:

They want to focus on their customers and their interests, so they market their products to a specific audience. hope this helps :)

4 0
2 years ago
Given the variables full_admission_price and discount_amount (already defined), write an expression corresponding to the price o
stiks02 [169]

Answer:

if full_admission_price = f and discount_amount = d

=> Price of a discount admission = d/f

total_weight

quantity

weight of one item = total_weight/quantity                      

for i in range(80, 18, -2):

   print(i, end=' ')

Explanation:

The first two questions are just mathematical to get a single quantity given some relationship. So, its basically division

For the python code, I used the python's range function which takes in three arguments. The first one is the starting value, the second one is the terminating value which is the number before the terminating value and the last one specifies the common difference popularly known as step in the language. Since the step is 2, only even numbers are printed out. In the print function, I made use of the end keyword specifying a space (' ') as the end. This ensures that the print is done in the same line with a space seperating them. Without that specification, each result will printed in a newline

7 0
3 years ago
Other questions:
  • Kurt is editing a table in his powerpoint that displays accounting formulas and when to use them. he wants to remove the table s
    15·1 answer
  • The layout button is located in the ____ group on the home tab?
    14·1 answer
  • A word or line of a paragraph at the top of a page hanging indent is called ______
    8·1 answer
  • Effective feedback should focus on the behavior, not the person.<br><br> True<br> False
    9·2 answers
  • Which of the following involves writing hidden messages so that only the sender and intended recipient know a message exists? St
    5·1 answer
  • Declare an ArrayList of Strings. Add eight names to the collection. Output the Strings onto the console using the enhanced for l
    9·1 answer
  • How scientist and technology beliefs society
    14·1 answer
  • The system where the unit of measurement is centimeter
    15·1 answer
  • I need help 50 points and brainiest if you answer
    10·2 answers
  • Your organization has 20 employees who need an accounting software update installed. Due to a miscommunication, the purchaser on
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!