/* TOGGLE CASE OF STRING */ #include<stdio.h> int main() { char str[100]; int i; printf("Please enter a string: "); // gets(str); // fgets is a better option over gets to read multiword string . fgets(str, 100, stdin); // Following can be added for extra precaution for '\n' character // if(str[length(str)-1] == '\n') str[strlen(str)-1]=NULL; for(i=0;str[i]!=NULL;i++) { if(str[i]>='A'&&str[i]<='Z') str[i]+=32; else if(str[i]>='a'&&str[i]<='z') str[i]-=32; } printf("String in toggle case is: %s",str); return 0; }
Toggle case of string
Subscribe to:
Post Comments (Atom)
very nice code
ReplyDeleteAttention everyone, the file provided above is not working. I have been looking for the working file and finally found it.
Delete✔️Click Here To Download http://gestyy.com/e0GAyS
✔️Click Here To Download
✔️Click Here To Download http://exe.io/XONVsO6l
✔️Click Here To Download
✔️Click Here To Download
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Mn.
..
.
.
.
..
.
.
.
.
.
.
.
.
.
.
..
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.cxx
.sdcccxxx
Great job n i have been following your .n i want reverse the words of a string like
ReplyDeleteinput:- i am a boy.
output:- boy. a am i
kindly send me the answer of it
http://cbasicprogram.blogspot.in/2012/05/string-reverse-strrev.html
Deletewhat is the use of str[i] != NULL....i don't know....
ReplyDeleteto find end of string
DeleteWhat is code for this program?,if i input SK JAHANGIR ALAM and output wil be S.J,ALAM
ReplyDeletewhat does this line do?
ReplyDeletestr[i]+=32
It will increase the ASCII value of the character . As the difference of ASCII value between any lowercase character and uppercase character is 32 ,we add 32 which makes uppercase character to its respective lowercase. A=65, a=97 => A+32='a' .so A became 'a' by adding 32 and vice versa in else part.
Deletethis code needs lot of memory locations can u plz tell me a fast and reliable code
ReplyDeleteif(str[i]>='A'&&str[i]<='Z')
Deletestr[i]=str[i]+'a'-'A';
elseif(str[i]>='a'&&str[i]<='z')
str[i]+'A'-'a';
nice article for beginners.thank you.
ReplyDeletewelookups C++
javacodegeeks