C Program to Toggle Case of all Characters in a String

In this tutorial you will learn about the C Program to Toggle Case of all Characters in a String and its application with practical example.

C Program to Toggle Case of all Characters in a String

In this tutorial, we will learn to create a C program that will Toggle the Case of all Characters in a String in C programming.

Prerequisites.

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C programming.
  • Conditional Statements in C programming.

What is a String?

The String is a collection character. The character is a single entity in the English language or in any word. These characters can be any alphabets in lower case or upper case.

The lower case means the small letters. And the upper case means the capital letters of the English language.

For Example:-

In the string “Hello”, there are five characters, they are as follows

Here,

‘H’ is a character in the Upper case.

‘e’ is a character in the lower case.

‘l’ is a character in the lowercase.

‘l’ is a character in the lower case.

‘o’ is a character in the lowercase.

Algorithm:-

Program to Toggle Case of all Characters in a String:-

First, we will take the input string from the user. Then will pass that String in the conditional statements to check and change the case of every character. It means the lower case character will be converted to the upper and upper case to lower.

With the help of this program, we can Toggle the Case of all Characters of the String.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

  • str1[100] = it will hold the String value for the input.
  • i = it will hold the integer value for the loop.

Input String from the user.

Toggle all characters.

Printing toggled String.

In this tutorial we have learn about the C Program to Toggle Case of all Characters in a String and its application with practical example. I hope you will like this tutorial.