Question: Write a function in C called that takes a string and return a new string built from this string after replacing each alphabetical character by

Write a function in C called that takes a string and return a new string built from this string after replacing each alphabetical character by the opposite alphabetical character.
'a'becomes 'z','Z'becomes 'A''d'becomes 'w','M'becomes 'N' and so on.
Case is not changed.
Must not use sprintf or other libc functions.
Input: "abc" Output: "zyx"
char* a_mirror(char* str)
{
for (i =0; i < strlen(str); i++)
{
if (str[i]>=97 && str[i]<=122)
str[i]=('m'-(str[i]-'n'));
else if (str[i]>=65 && str[i]<=90)
str[i]=('M'-(str[i]-'N'));
else
str[i]= str[i];
}
return str;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!