×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Accept a string and convert it in upper case - String Read string and convert it in Sentence case - String
Accept a string and convert it in proper or Title case - String - String - C Language
12742    Arnab De    27/04/2019

Write a program to accept a string or name from the user and convert it as Proper Case or Title Case or Capitalised first Character of each word.

Read a string from user using gets(). Now travel the whole string and check it is an alphabet or Not. If it is an alphabet then check it position. If it is first character of the string or the character posted just after a space or first character of any word and it is a small character [ASCII between 97 - 122], then convert it into upper case letter and other all charcter convert into lower case letter. Now print the string using puts().

softetechnologies
int main()
{
	char str[30],i;
	//READ A STRING
	printf("Enter A String: ");
	gets(str);
	for(i=0;str[i]!='\0';i++)
	{
		if((str[i]>=65 && str[i]<=90) ||(str[i]>=97 && str[i]<=122))
		{
			if(i==0 || str[i-1]==' ')
			{
				if(str[i]>=97 && str[i]<=122)
				{
					str[i]=str[i]-32;
				}
			}
			else
			{
				if(str[i]>=65 && str[i]<=90)
				{
					str[i]=str[i]+32;
				}
			}
		}
	}
	//PRINT THE OUTPUT
	printf("Result : ");
	puts(str);
	return 0;
}
softetechnologies
Accept a string and convert it in upper case - String Read string and convert it in Sentence case - String
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Rabindranath Tagore
You can't cross the sea merely by standing and staring at the water.
Rabindranath Tagore
1103
64.31
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     47404
25/06/2018     39491
01/01/2018     39105
28/06/2017     37000
02/08/2017     35725
01/08/2017     29962
06/07/2017     29748
15/05/2017     29229
14/07/2017     25118
11/09/2018     24261
softetechnologies