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
Alex73 [517]
3 years ago
9

Create a program that includes a function called toUpperCamelCase that takes a string (consisting of lowercase words and spaces)

and returns the string with all spaces removed. Moreover, the first letter of each word is to be forced to its corresponding uppercase. For example, given "hello world" as the input, the function should return "HelloWorld". The main function should prompt the user to input a string until the user types "Q". For each string input call the function with the string and display the result. (Hint: You may need to use the toupper function defined in the header file.)
Computers and Technology
1 answer:
astraxan [27]3 years ago
8 0

Answer:

#include<iostream>

using namespace std;

//method to remove the spaces and convert the first character of each word to uppercase

string

toUpperCameICase (string str)

{

string result;

int i, j;

//loop will continue till end

for (i = 0, j = 0; str[i] != '\0'; i++)

{

 if (i == 0)       //condition to convert the first character into uppercase

  {

  if (str[i] >= 'a' && str[i] <= 'z')   //condition for lowercase

  str[i] = str[i] - 32;   //convert to uppercase

  }

if (str[i] == ' ')   //condition for space

  if (str[i + 1] >= 'a' && str[i + 1] <= 'z')   //condition to check whether the character after space is lowercase or not

  str[i + 1] = str[i + 1] - 32;   //convert into uppercase

if (str[i] != ' ')   //condition for non sppace character

  {

  result = result + str[i];   //append the non space character into string

  }

}

//return the string

return (result);

}

//driver program

int main ()

{

string str;

char ch;

//infinite loop

while (1)

{

fflush (stdin);

//cout<< endl;

getline (cin, str);   //read the string

//print the result

//cout<< endl << "Q";

// cin >> ch; //ask user to continue or not

ch = str[0];

if (ch == 'q' || ch == 'Q')   //is user will enter Q then terminatethe loop

  break;

cout << toUpperCameICase (str);

cout << endl;

}

return 0;

}

You might be interested in
A user can set the security and privacy settings on what is displayed in the message bar from the ________ within the options me
djverab [1.8K]
Depends on the Operating System
6 0
3 years ago
Given an list of N integers, Insertion Sort will, for each element in the list starting from the second element: Compare the ele
Elena L [17]

Answer:

def insSort(arr):

ct=0;

for i in range(1, len(arr)):

key = arr[i]

j = i-1

while j >=0 and key < arr[j] :

arr[j+1] = arr[j]

j -= 1

ct=ct+1;

arr[j+1] = key

return arr,ct;

print(insSort([2,1]))

Output of the program is also attached.

8 0
3 years ago
What should you change if you want one particular slide to have a different arrangement of text box placeholders?
Ganezh [65]
<span>slide layout you should change the slide layout hope this helps  ................</span>
8 0
3 years ago
The National Archives is part of the federal government, which means that its content:
RUDIKE [14]

Answer:

belongs to everyone.

Explanation:

A National Archive can be defined as the collection of data (informations) and documents by the government of a particular country for record keeping purposes.

Basically, these documents comprises of information about important and historical events that have happened in the country or events generally related with the country.

Hence, the National Archives is part of the federal government, which means that its content belongs to everyone. This is simply because the federal government is a government of the people, for the people and by the people. Thus, the ownership of governmental institutions or agencies belongs to the general public i.e the citizens of the country.

4 0
3 years ago
IF YOU GET 5/5 RIGHT YOU WILL GET BRAINLIEST AND 50 [POINTS
natta225 [31]

Answer:

The sort function

Explanation:

Because it will sort all the numbers.

4 0
2 years ago
Read 2 more answers
Other questions:
  • To change the overall design of an entire document to include colors, fonts, and effects, a user should apply a?
    8·2 answers
  • Which one of the following items is an example of software?
    15·1 answer
  • Which statement is true?
    5·2 answers
  • Where (what memory location) is the data read from for the following code:
    12·1 answer
  • What was original name<br> whoever answers first gets brainly crown
    9·1 answer
  • What is the difference between skew and rotate in the MS Paint application?
    14·2 answers
  • After you log in to PowerPoint Online, what is the first thing you need to do to start creating a presentation?
    12·2 answers
  • If an if-else statement is true, it will include which kinds of results?
    13·1 answer
  • Draw a flowchart that solve the problem of calculating the average of 5 numbers.
    7·1 answer
  • Question 2 of 10
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!