C Program to convert lowercase character into uppercase and vice versa using function

C Program to convert lowercase character into uppercase and vice versa using function

This is the example of c-programming. You can edit and compile code in your own way on clicking button. If you have better solution or you found any error on code, then give us suggestion.

Full Code:

Code Explanation :

Here, the function alConversion() is called by passing refrence (i.e address). Thus, the function has character pointer as an argument which receive address of variable ch (i.e passed in function in main()).

The content of address pointed by pointer c is converted into equivalent uppercase if it is in lowercase.

As the function changes the content of address pointed by c (i.e address of ch), the value of variable ch in main() function also changes.

As the pointer variable c in alConversion() function is pointing to ch variable in main() function, the change in content of address pointed by pointer variable c reflects change in variable ch in main().

Thus, the variable ch receives changed value from alConversion() even without returning the value (i.e void return type). We can rewrite this program using call by values as follow.

int alConversion(char);
int main(){
	char ch;
	printf("Enter a character [a-zA-Z]. n");
	scanf("%c", &ch);
	if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')){
		printf("The equivalent character is %c", alConversion(ch));
		printf("Please input valid character.");
	return 0;
int alConversion(char c){
	if(c >= 65 && c <= 90){
		c += 32;
	else if(c >= 97 && c <= 122){
		c -= 32;
	return c;

You can do same problem without using function. If you are basic in c program, then only use this methos.

C program to convert Lowercase to uppercase and vice versa with function

int main(){
	char c;
	printf("Enter a character [a-zA-Z] = ");
	scanf("%c", &c);
	if (isalpha(c)){  // this can also replace as (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
		if(c >= 65 && c <= 90)
		    c += 32;
		else if(c >= 97 && c <= 122)
		    c -= 32;
		printf("nThe equivalent character is %c", c);
		printf("nPlease input valid character.");
	return 0;

The algorithm and flowchart of the above program is given below :


STEP 1 : Start

STEP 2 : Declare character c

STEP 3 : Read character and store on c

STEP 4 : IF isalpha(c) THEN
            STEP 4.1 : IF c >= 65 && c <= 90 THEN
                            STEP 4.1 : c += 32;
            STEP 4.2 : ELSE IF 
                            STEP 4.1 : c -= 32;
            STEP 4.3 : Print c as character
            Print "Please input valid character."

STEP 5 : end


C Program to convert lowercase character into uppercase and vice versa using function

If you got any issue on understanding this example then leave comment below.

Our example mainly covers following topics in any programing

  • Basic Programs
  • Number Programs
  • Array Programs
  • Matrix Programs
  • Pattern Programs
  • String Programs
  • Tree Programs
  • Singly Linked List Programs
  • Circular Linked List Programs
  • Doubly Linked List Programs

Here we share programs on various topics such as array strings, series area & volume of geometric figures, mathematical calculation algorithms for sorting & searching and much more.Our goal is to provide you with the perfect solution to all the programming problems you may have encountered either during interviews or in class assignments. If you don’t find what you are looking for then please drop a line in the comment section of example page or you can request from account page so that we can get it added to the below collection of programs. Happy Learning!!

If you are confident with the above programs and are able to successfully understand and run them without any problems then it is time for you to take a step further and learn comprehensive programming principles using examples and flow diagrams. Here is the link: Programming tutorial lists .

If you find this example helpful, don't forget to share it with your friends. And stay updated with us by subscribing adzetech.

If you find any code error or grammetical error then you can suggest for example improvement on clicking below button.

Leave comment

Comments (1)


What are you searching for....?


Subscribe us on youtube to get our videos updates firstly on youtube.


To receive updates on the latest news, tutorials and special offers, subscribe to our email newsletter today!


We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Privacy Policy That's Fine