# Toggle String Hackerearth Problem Solution – Coder In Me

You have been given a String S consisting of uppercase and lowercase English alphabets. You need to change the case of each alphabet in this String. That is, all the uppercase letters should be converted to lowercase and all the lowercase letters should be converted to uppercase. That is Toggle String. You need to then print the resultant String to output.

Input Format Of Toggle String

The first and only line of input contains the String S

Output Format
Print the resultant String on a single line.

Constraints
1<=|S|<=100, where S denotes the length of string S.

Let Us  See Example Of  Toggle String –

Sample Input Sample Output How We Can Solve Toggle String Problem-

• Firstly know about the ASCII value of capital alphabet and small alphabet to sort this problem.
• Give the string S as input And check it character by character.
• If  S[i] greater than and equal 65 AND less than and equal 90, Add 32 in S[i] to convert into lower case.
• OTHERWISE subtract 32 from S[i] to convert lower case into upper case.
HERE, i represents natural number.. 0,1,…… AND S[i] represents string with index.
##### Explanation

let a string and check it with it’s index character by character.

INPUT –  sHikHA
S = s this is not satisfy the our giving condition. So SUBTRACT 32 to the screen output as  S.

S = H this is greater than 65 and less than 90. So ADD 32 to the screen output as h.

AND SO ON…. OUTPUT-  ShIKha CODE:

```#include <stdio.h>

int main()
{
char S; /* string as character type
int i;
scanf("%s",S);  // Reading input from STDIN
for(i=0;S[i]!='\0';i++)
{
if(S[i] >= 65 && S[i] <= 90)
S[i] = (char)(S[i] + 32);
else
S[i] = (char)(S[i] - 32);
}
printf("%s",S);  // Writing output to STDOUT
return 0;
}```

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme