C Program to convert lowercase string to uppercase


In this program, You will learn how to convert lowercase string to uppercase in c.


hello abc => HELLO ABC

welcome to xiith => WELCOME TO XIITH

Example: How to convert lowercase string to uppercase in c.

#include<stdio.h>

int main(){

    char str[100];
    int i=0;

    printf("Enter a string:");
    scanf("%[^\n]%*c", str); 

    while(str[i] != '\0'){
        i++;
    }

    for(int j = 0; j < i; j++){
        if(str[j] >= 97 && str[j]<=122)
            str[j] = str[j]-32;
    }
    printf("Uppercase string:%s",str);

    return 0;
}

Output:

Enter a string:Welcome to xiith
Uppercase string:WELCOME TO XIITH