This is a C++ program that takes a sentence as input and converts it to sentence case (i.e., capitalizes the first letter of the first word and converts all other letters to lowercase). The program works as follows:
Overall, this program demonstrates how to convert a sentence to sentence case in C++ by manipulating the ASCII codes of the characters in the string.
#include<iostream> #include<string> using namespace std; int main() { int i; string a; cout<<"\nEnter the Sentence:"; getline(cin,a); cout<<"\nSentenced case:"; if(a[0]>=97&&a[0]<=122) { a[0]-=32; } for(i=1;a[i]!='\0';i++) { if(a[i]>=65 &&a[i]<=90) { a[i]+=32; } } for(i=1;a[i]!='\0';i++) { if(a[i]==46 && a[i+1]==32) { if(a[i+2]>=97&&a[i+2]<=122) { a[i+2]-=32; } } } cout<<a; return 0; }To download raw file Click Here
Enter the Sentence:tutor joe's computer education Sentenced case:Tutor joe's computer education
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions