/* * To capitalize a sentence each word starts * with a capital letter and all the other letters are small. * A word starts after a blank or is at the beginning of the string. A word ends * with a blank or fullstop or comma or at the end of the string. * @author-Karan Narain(karan@iitk.ac.in) * */ #include #include void capitalize(char *A) { char *x; x=A; while(*x!='\0') { //This is the first letter of a new word if(*x>='a' && *x<='z') *x=*x-32; x++; while(*x!=' ' && *x!='\0') { if(*x>='A' && *x<='Z') *x=*x+32; x++; } //if this character is a space if(*x==' ') x++; } printf("\nThe capitalized sentence is "); puts(A); } int main() { char A[200]; printf("Enter the sentence\n"); gets(A); capitalize(A); return 0; }