Last active
August 29, 2015 14:02
-
-
Save abouolia/a50603b3d94dd4060e1a to your computer and use it in GitHub Desktop.
Upper/Lower Case in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<string.h> | |
#include<ctype.h> | |
char *uppercase( char str[256] ); | |
char *lowercase( char str[256] ); | |
main(){ | |
char str[256] = ""; | |
printf("Please Enter Your Name Fully\t"); | |
scanf("%s", str); | |
printf("Upper Case: %s \t", uppercase( str ) ); | |
printf("Lower Case: %s", lowercase( str ) ); | |
} | |
//to convert any string to upper case | |
char *uppercase( char str[256] ){ | |
int i; | |
for( i = 0; i < strlen(str); i++ ){ | |
str[i] = toupper(str[i]); | |
} | |
return str; | |
} | |
//to conver any string to lowercase | |
char *lowercase( char str[256] ){ | |
int i; | |
for( i = 0; i < strlen(str); i++ ){ | |
str[i] = tolower(str[i]); | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment