Online visitors

People learning around the world

Online

—

Active in the last 10 minutes

Online visitors by country Circles show approximate country locations. The country list provides the visitor counts.

Circles represent countries, not exact visitor locations.

Country

Online

Loading country activity…

    C Program to Change String Case

    C Programming Examples


    This C program is used to change string case with and without using strlwr and strupr functions.

    Lowercase using strlwr function

    Program:

    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
        char string[] = "Strlwr in C";
        printf("%s\n",strlwr(string));
        return  0;
    }

    Uppercase using strupr function

    Program:

    #include <stdio.h>
    #include <string.h>
    
    int main()
    {
        char string[] = "strupr in c";
        printf("%s\n",strupr(string));
        return  0;
    
    }

    Lowercase without strlwr function

    Program:

    #include <stdio.h>
    
    void lower_string(char*);
    
    int main()
    {
        char string[100];
        
        printf("Enter a string to convert it into lower case\n");
        gets(string);
        
        lower_string(string);
        
        printf("Entered string in lower case is \"%s\"\n", string);
        
        return 0;
    }
    
    void lower_string(char *string)
    {
        while(*string)
        {    
            if ( *string >= 'A' && *string <= 'Z' ) 
            {
                    *string = *string + 32;
            }
            string++;    
        }
    }

    Uppercase without strupr function

    Program:

    #include <stdio.h>
    
    void upper_string(char*);
    
    int main()
    {
        char string[100];
        
        printf("Enter a string to convert it into upper case\n");
        gets(string);
        
        upper_string(string);
        
        printf("Entered string in upper case is \"%s\"\n", string);
        
        return 0;
    }
    
    void upper_string(char *string)
    {
        while(*string)
        {    
            if ( *string >= 'a' && *string <= 'z' )
            {
                    *string = *string - 32;
            }
            string++;        
        }
    }


    Found This Page Useful? Share It!
    Get the Latest Tutorials and Updates
    Join us on Telegram

    Notifications

    Updates are enabled for this browser.

    Receive new tutorials, articles and learning resources. You can turn updates off anytime.

    Test browser code

    Use this code in admin to send a test notification to this browser.