Q54 Implement your own toupper(), tolower() and isupper() functions.

toupper() library function is used to covert a given letter to uppercase.

tolower() library function is used to covert a given letter to lowercase.

isupper() library function is used to check a given letter is upper case or not.

 

User defined function of toupper().

int own_toupper(int chr)

{

if(chr >= ’a’ && chr <= ’z’)

return(chr + ‘A’ – ‘a’);

else

return(chr);

}

 

User defined function of tolower().

int own_tolower(int chr)

{

if(chr >= ‘A’ && chr <= ‘Z’)

return(ch + ‘a’ – ‘A’);

else

return(chr);

}

 

User defined function of isupper().

int own_isupper(int chr)

{

if(chr >= ‘A’ && chr <= ‘Z’)

return(1);  /* Returning 1 means true, its uppercase */

else

return(0);  /* Returning 1 means true, its uppercase */

}

One comment

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.