convert lower to upper case

 In this example, you will learn about the conversion of the lower case to the upper case of the string.


code:

#include<iostream>

#include<cstring>

using namespace std;


void lowertoupper(char *);

int main()

{

char stringtake[100];

cout<<" Enter the string to convert into upper case";

cin.getline(stringtake,100);


cout<<endl;

lowertoupper(stringtake);



return 0;


}

void lowertoupper(char *str)

{

for(int i=0;str[i]!='\0';i++)

{

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

{

str[i]-=32;

}

cout<<str[i];

}

}

Output:

convert-lower-to-upper

In this example, first of all, declare the function which accepts the char pointer which is used to convert the character array from lower to upper case. 

In this function, one for loop is used which is terminated when null is reached, and if check check the char which are in between the lower case and sucstract 32 in the ascii of the character to convert into upper case.In the end,display the string.

During the calling, the function just passes the character array in it.


Comments

Popular posts from this blog

Diferrence between flutter and react native

Flutter Widgets

Flutter layout