hey guys u no any thing bout tex files...........
any thing?? i have a few questions to figure out.......... but if u have any advice on what i need to no wrt figuring out these coding questions please help me... i would gr8tly appr. it....
heres the question:
and wrt them can u suggest any thing applicable to them and i hope to figure it out....

Write a program to average real numbers input from a text file called “input.txt”. Each line of the text file will contain a single number to be averaged. Collect and sum numbers from the file until there are no more numbers in the file, then compute the average. Write the sum, the number of entries in the file and the average to another text file called “output.txt”.

Create the following text file and use as your input file:
10
15
20
45
6
19
33
21

Write a program to produce a sailing table for mariners to the file “sailing.txt”. The program should read the current wind speed in knots from an input file called “speed.txt”, and write a sailing forecast according to the following rules:
If the wind is less than 10 knots, ‘Fair Sailing Ahead’.
If the wind is between 10 and 20 knots, ‘Fair Warning’.
If the wind is between 20 and 30 knots, ‘Experts Only’.
Finally, if the wind is above 30 knots, ‘Use the motorboat!’.
The program should output the wind speed in knots together with the appropriate message.
The program should continue to read and process wind speed values from the input file until there are no more values in the file.

Test your program on the following “speed.txt” file:
10
20
30
5
15
25
35

thanks.... ttul
bye

You're welcome.

Read the rules.

Including the use of u for you, no for know, etc.

Open a text file for reading by making an object of the ifstream class. Once it's open and everything is good, you can use it just like cin. Objects of the ofstream class work the same way and can be used like cout:

#include <fstream>
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    ifstream ifp("input.txt");

    if (!ifp)
    {
        cerr << "Could not open file\n";
        return EXIT_FAILURE;
    }

    ofstream ofp("output.txt");

    if (!ofp)
    {
        cerr << "Could not open file\n";
        return EXIT_FAILURE;
    }

    int input;

    while (ifp >> input) ofp << input;
}

Well what language are you using?

wow dis is a fast brilliant code lad.... thanks alot...... i will c and i hope to get tru..................................

commented: L33T kiddie -4
commented: ugh. +12
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.