C++ Program to convert a String into Title Case [DEVCPP/GCC]


TITLE CASE

A sentence is said to be in Title Case if all of its constituent words begins with an Uppercase Letter.

                eg:   Input:    vijay dinanath chouhan
                       Output:  Vijay Dinanath Chouhan

PROGRAM

//Program to convert a string into Title case

# include <iostream>

using namespace std;

int main()
{
int i;
char a[30];
cin.getline(a,30);   //To Input a String
a[0]=a[0]-32;        //For First Letter

for(i=0;a[i]!='\0';i++)
{
if(a[i]==' ')
{
a[i+1] = a[i+1]-32;
}
}

cout<<a;
return 0;
}

OUTPUT

C++ Program to convert a String into Title Case with output

Share this

Related Posts

FIND US ON FACEBOOK!