Program to toggle each character in a string | Faceprep

Program to toggle each character in a string | Faceprep

The program to toggle each character in a string is discussed here. A string is given as input in which all the lower case letters are converted to upper case and the upper case letters are converted to lower case.

program to toggle each character in a string


For example, consider the following string

Input: FacePrep

Output: fACEpREP

Input: FocucAcadeMy

Output: fOCUSaCADEmy


Program to toggle each character in a stringClick here to learn more about FACE Prep PRO


Algorithm to toggle each character in a string

  • Input the string from the user.
  • Traverse the string character by character.
  • If the scanned character is upper case, convert it to lower case.
  • If the scanned character is lowercase, convert it to uppercase.

The program to toggle each character in a string is given below.

@@coding::1@@


Time complexity: O(n)

The program to toggle each character in a string using standard library functions is given below.


@@coding::2@@



Recommended Programs


program to toggle each character in a string

c