To print the string in first case using C


Levels of difficulty: / perform operation:

C program to print the string in first case.

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	char s[100];
	int len,i;
	clrscr();
	printf("\nENTER A SENTENSE: ");
	gets(s);
	len=strlen(s);
	printf("\n");
	for(i=0;i<len;i++)
	{
                if((i==0 && s[i]>=97 && s[i]<=122) || (s[i-1]==32 && s[i]>=97 && s[i]<=122))
			printf("%c",s[i]-32);
		else
		{
			if(i!=0 && s[i-1]!=32 && s[i]>=65 && s[i]<=90)
				printf("%c",s[i]+32);
			else
				printf("%c",s[i]);
		}
	}
	getch();
}


Output







Quantitative Aptitude
Reasoning
Programming
Interview