Write a function which takes a C string as an input and converts it to all upper
ID: 3660962 • Letter: W
Question
Write a function which takes aC stringas an input and converts it to all uppercase characters. For each lowercase character in theC string, simply subtract 32 from it to form the uppercase character. Any non-alphabetic character in theC stringshould not be changed. You are not allowed to use any other functions to do this. Do not write a main function. Your function does not do anycin
orcout. Hint: lowercase characters are between 'a' and 'z' where the value of 'z' equals the value of 'a' + 25. Remember,C stringsare terminated with the '' character. Make sure to properly format all your code.
Explanation / Answer
void convertToUpper( char base[]) { char temp; for (int i = 0; i 'Z' && base[i] < 'a') || base[i] > 'z') continue; else if( base[i] >= 'a') base[i] = base[i] - 32; } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.