convert lower to upper case

string conversion:

 Here is the code of convert lower case string to upper case in the c programming language. The concept of ASCII involves in the conversion of string.  



code:


#include<stdio.h>


#define size 100


  void convet1st2Capital(char str[]);


int main(void){


char str[size];


printf("Enter the string to capitalize initials:\n");


gets(str);


convet1st2Capital(str);



}




void convet1st2Capital(char str[]){




int s = 0;


while (!(str[s] == '\0')){


if (str[s] >= 'a' && str[s] <= 'z'){


str[s] -= 32;


}




 


s++;


}




printf("%s", str);


}



Output:

convert-upper-case

In this example,declare the global variable for size of character array and function to convert the lower case string to upper case string .

In the function, the loop is used to check the lower case character and convert into the upper by subtracting the 32 in the character ASCII.In the last,display the string .

Comments

Popular posts from this blog

Diferrence between flutter and react native

Flutter Widgets

Flutter layout