check uppercase or lowercase in c code example

Example 1: C string convert All Uppercse To Lowercase

#include <stdio.h>
#include <string.h>

int main() {
   char s[100];
   int i;

   printf("\nEnter a string : ");
   gets(s);

   for (i = 0; s[i]!='\0'; i++) {
      if(s[i] >= 'A' && s[i] <= 'Z') {
         s[i] = s[i] + 32;
      }
   }

   printf("\nString in Lower Case = %s", s);
   return 0;
}

Example 2: check if character is uppercase c

int isUpper(char c) {
  // check if the argument is the uppercase bound
  if (c >= 'A' && c <= 'Z') return 1;
  else 						return 0;
}

Tags:

C Example