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

Need to write the follwing function with the following purpose Function: char* c

ID: 3541610 • Letter: N

Question

Need to write the follwing function with the following purpose


Function:

char* caseChangeCopy(char* destination, const char* source)


Purpose:

Copy a string in which the case of each lowercase character is shifted to uppercase (and uppercase to lowercase), from the address specified by source to that specified by destination. Return a pointer to the start of the copied string.


You can use the character functions found in the C standard library header file <cctype> to determine whether a character is an uppercase or lowercase letter, and to convert letters from one case to the other.

Explanation / Answer

#include<iostream>

using namespace std;




char* caseChangeCopy(char* destination, const char* source)

{

int i = 0;

while(source[i]!='')

{

if(source[i] >= 65 && source[i] <= 90)

destination[i] = source[i] + 32;

else if(source[i] >= 97 && source[i] <= 122)

destination[i] = source[i] - 32;

i++;

}

destination[i] = source[i];

return destination;

}


int main()

{

char names[]="FreDdO";

char name[100];

cout << "caseChangeCopy in "FreDdO". ";

caseChangeCopy(name, names);

cout << name << endl << endl;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote