Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,926 questions

51,859 answers

573 users

How to convert lowercase letter to uppercase and uppercase letter to lowercase in C

2 Answers

0 votes
#include <stdio.h>
  
int main(void)
{
    char s[] = "The Last Line Of Code";
    int i;
    
	// A - 65 .. Z - 90 (ASCII)
 	// a - 97 .. Z - 122 (ASCII)
    // 97 - 65 = 32
	
    while (s[i])
	{
        if (s[i] >= 97 && s[i] <= 122)
			s[i] = s[i] - 32;
		else if (s[i] >= 65 && s[i] <= 90)
				s[i] = s[i] + 32;
		i++;
	}
	
	puts(s);
     
    return 0;
}
  
   
/*
     
run:
     
tHE lAST lINE oF cODE

*/

 



answered Jan 29, 2016 by avibootz
0 votes
#include <stdio.h>
  
int main(void)
{
    char s[] = "The Last Line Of Code";
    int i;
    
	// A - 65 .. Z - 90 (ASCII)
 	// a - 97 .. Z - 122 (ASCII)
    // 97 - 65 = 32
	
    while (s[i])
	{
        if (s[i] >= 'a' && s[i] <= 'z')
			s[i] = s[i] - 32;
		else if (s[i] >= 'A' && s[i] <= 'Z')
				s[i] = s[i] + 32;
		i++;
	}
	
	puts(s);
     
    return 0;
}
  
   
/*
     
run:
     
tHE lAST lINE oF cODE

*/

 



answered Jan 29, 2016 by avibootz

Related questions

3 answers 395 views
3 answers 399 views
2 answers 301 views
2 answers 274 views
1 answer 132 views
1 answer 152 views
...