How to convert uppercase letter to lowercase without library functions in C

3 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] >= 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
edited 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;
		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] = 'a' + s[i] - 'A';
        i++;
    }
     
    puts(s);
      
    return 0;
}
   
    
/*
      
run:
      
The last line of code
 
*/

 



answered Jan 29, 2016 by avibootz

Related questions

...