Answer to Question #24476 in C++ for arem marcial

Question #24476
Write a program that asks the user to enter a word and display it in uppercase letters. (in upperLetter.txt)
1
Expert's answer
2013-02-18T11:38:12-0500
#include<iostream>
#include<string>
#include<fstream>
#include <stdio.h>
using namespace std;

int main()
{

cout<<"Please input some word : ";
string inputString;
getline(cin,inputString);

for(int i=0;i<inputString.length();i++)
{
if(isalpha(inputString.at(i)))
{
inputString.at(i) = toupper(inputString.at(i));
}
}

cout<<"\nYoure word in upper case : "<<inputString<<endl;
string fileName = "upperLetter.txt";
ofstream fout(fileName);
if(fout.is_open())
{
fout<<inputString;
fout.close();
cout<<"The word was written to the file : "<<fileName<<endl;
}
cin.clear();
cin.get();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS