Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ - Write a program that initializes an array of characters with the phrase, “

ID: 3891331 • Letter: C

Question

C++ - Write a program that initializes an array of characters with the phrase, “Take me to Clearwater Beach!”. Using pointers, scan the array to make each character upper case. The catch: you may NOT use the isupper(), islower(), toupper(), or tolower() functions. You must calculate whether a character is upper or lower case, and use the same logic to convert to upper case where applicable.

Hints:

*cptr >= ‘a’ && *cptr <= ‘z’

Assuming the ASCII value for ‘a’ is greater than ‘A’, how could you use an expression like, (‘a’ – ‘A’) to convert to upper case?

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

char a[]="Take me to Clearwater Beach!";

int i=0;

while (*(a+i)!='')

{

if (*(a+i)>='a' && *(a+i)<='z')

*(a+i)=*(a+i)-32;

i++;

}

i=0;

while (*(a+i)!='')

{

cout<<*(a+i)<<" ";

i++;

}

}