Answer to Question #296484 in C++ for Bee

Question #296484

Write a C++ recursive function that takes an array of words and returns an array

that contains all the words capitalized


1
Expert's answer
2022-02-11T21:12:06-0500
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

string str = "";

string toUp(string s) {
	
	if (s.length() == 0) {
		return str;
	}
	else {
		char c = toupper(s[0]);
		str += c;
		s.erase(0, 1);
		toUp(s);
	}
	return str;
}

int main() {
	string s = "qwerty Hello PPpp";
	cout << toUp(s);
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog