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

Hire a programmer

Popular posts from this blog

CSS selector

C program to convert decimal to binary number

C Program to convert binary to decimal number