×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Read string and convert it in Sentence case - String Accept a String and Reverse It - String
Initial of the name - String - String - C Language
2719    Arnab De    15/05/2019

Accept a name and print the initial of the name.

Read a string from user using gets() function. Now travel the whole string and pick out the first character of every word and convert it into upper case and concat a '.' character. Now pick out the last word an concat it to the result.

softetechnologies
int main()
{
	char str[30],res[30],i,w,k=0;
	//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]==' ')
			{
				w=i+1;
				if(str[i]>=97 && str[i]<=122)
				{
					str[i]=str[i]-32;
				}
				res[k++]=str[i];
				res[k++]='.';
			}
		}
	}
	k--;
	for(i=w;str[i]!='\0';i++)
	{
		if(str[i]>=65 && str[i]<=90)
		{
			res[k++]=str[i]+32;
		}
		else
		{
			res[k++]=str[i];
		}
	}
	res[k++]='.';
	res[k]='\0';
	//PRINT THE OUTPUT
	printf("Result : ");
	puts(res);
	return 0;
}
softetechnologies

Enter A String: rabinDra natH tagore
Result : R.N.Tagore.

Read string and convert it in Sentence case - String Accept a String and Reverse It - 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.
Sri Sri Ramakrishna Paramahamsa
God is in all men, but all men are not in God; that is why we suffer.
Sri Sri Ramakrishna Paramahamsa
3298
75.02
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     52290
25/06/2018     44059
01/01/2018     42982
28/06/2017     40718
02/08/2017     39572
01/08/2017     33742
06/07/2017     33558
15/05/2017     32834
14/07/2017     29127
11/09/2018     29119
softetechnologies