Q:

Revise the loop that printed the first paragraph in text to instead change the elements in text that correspond to the first paragraph to all uppercase. After you’ve updated text, print its contents

0

Revise the loop that printed the first paragraph in text to instead change the elements in text that correspond to the first paragraph to all uppercase. After you’ve updated text, print its contents.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
#include <vector>
#include <string>

int main() {
  std::vector<std::string> text;

  std::string line;
  while (getline(std::cin, line))
    text.push_back(line);

  for (auto it = text.begin(); it != text.end() && !it->empty(); ++it)
    for (auto &c : *it)
      c = toupper(c);

  for (auto &elem : text)
    if (elem.empty())
      std::cout << std::endl;
    else
      std::cout << elem << " ";

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now