This program that I wrote will show you how to convert lowercase words in a given sentence into uppercase equivalent using C++ as my programming language. The C++ library file that I used to convert lowercase into uppercase is #include <cctype> this library file has a built in function called toupper() that enables the programmer to convert lowercase characters into uppercase characters. I hope you will find my work useful and beneficial in your learning how to program in C++.
Thank you very much.
Sample Output of Our Program
Program Listing
#include <iostream>
#include <cctype>
#include <string>
int main()
{
using namespace std;
string str;
cout << " Lower Case To Upper Case String Conversion 1.0";
cout << "\n\n";
cout << "Enter a String : ";
getline(cin,str);
for (size_t i = 0; i < str.length(); ++i)
{
str[i]=toupper(str[i]);
}
cout << "\n";
cout<<"\n Converted Results in Upper Case : " <<str << ".";
for (size_t i = 0; i < str.length(); ++i)
{
str[i]=tolower(str[i]);
}
cout<<"\n Converted Results in Lower Case : " <<str << ".";
cout << "\n\n";
system("PAUSE");
}
No comments:
Post a Comment