Write a program that will do the following:

1. Define a function that will read from a file text paragraph convert the whole paragraph into capital letters and print it on the screen after conversion.

2. Define a function that will count and return number of vowels in the above text.( a,e,i,o,u)

3. Write a main function that will call above functions to produce an output on sample text.

Recommended Answers

All 6 Replies

where is the code you have started to solve the problems? We will not write it for you. Write it a little bit at a time and your program will soon be written.

// really need help !!!!!!

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
using namespace std;

string capital ();

string capital() 
{
ifstream obj1 ("C:\\file1.txt")
getline.obj1;
????
}

bool vowels (string);

bool vowels (string s) 
{ ???? }


int main ()
{



return 0; 
}

> Write a program that will do the following:
No, you read the forum rules first, then post some effort.

commented: I completely agree. Well said! +2

There are lots and lots of examples here and other places on the net that show you how to read a file. I know there are also examples in your textbook, if you bothered to read and study it.

std::string line;
ifstream obj1 ("C:\\file1.txt")
while( getline( obj1, line) )
{
    // blabla
}
commented: well said, as usual :) +2

could you please help me and tell me how can i convert the whole paragraph into capital letters using <iomanip> library function ?

You don't need iomanip to do that. The macro toupper() will make the conversion for you

char c = 'a';
char upperc = toupper(c);

Now you will have to put something like that in a loop so that the entire line is converted to upper case.

If you are really really smart and know your stuff you can do it like this:

#include <algorithm> 
#include <string>
using namespace std;
...
...
std::string line = "Hello World";
transform(line.begin(), line.end(), line.begin(), toupper);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.