66 840
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #12514 in C++ for JX

Question #12514
How to correct the error? TQ

#include <iostream>
using namespace std;

void recursiveToLower(char str[])
{
if ( str[0] != '\0' ) {
str[0] = toupper( str[0] ); // do this char
recursiveToLower( str+1 ); // recursively do the remaining chars
}
}

int main()
{
char word[10] ;
cin >> word

cout << recursiveToLower(word);

system ("pause");
return 0;
}
Expert's answer
Here is corrected code:

#include <iostream>
using namespace std;
&
char* recursiveToLower(char str[])
{
& if ( str[0] != '\0' ) {
str[0] = toupper( str[0] );& // do this char
recursiveToLower( str+1 ); // recursively do the remaining chars
& }
& return &str[0];
}
&
int main()
{
char word[10] ;
cin >> word;

cout << recursiveToLower(word) <<"\n";
&
system ("pause");
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

Assignment Expert
07.08.12, 15:34

You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

JX
27.07.12, 19:14

Thank you very much for the answer. :)

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions