C examples for Data Type:char
Converts upper case letters to lower case, with a conditional expression instead of if-else.
#include <stdio.h> int lower(int c); int main(void){ char s[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int i = 0;/*from www .j a v a 2s . c om*/ while (s[i] != '\0') { printf("%c -> %c\n", s[i], lower(s[i])); i++; } return 0; } int lower(int c){ return (c >= 'A' && c<= 'Z') ? c + 'a' - 'A' : c; }