0

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.

3
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
Featured Replies
  • 1
    Salem 5,138   8 Years Ago

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

  • 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. [code] std::string line; ifstream obj1 ("C:\\file1.txt") while( getline( obj1, line) ) … Read More

0

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.

0

// 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; 
}
1

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

Comments
I completely agree. Well said!
1

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
}
Comments
well said, as usual :)
0

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

0

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);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.