Need a little bit of help :)

Hello, guys :)

I get that kind of question: Read from file all the numbers below, first row shows how much formulas you have ( must be show in program), after that the numbers a b c must be take in sum. So I have to get 10 answers of those formulas.
10
1 2 3
4 5 6
7 8 9
10 11 12
13 14 15
16 17 18
19 20 21
22 23 24
25 26 27
28 29 30

Thank you, Regards :)
There's a tutorial on files here (which probably tells you more than you need at this stage)
http://www.cplusplus.com/doc/tutorial/files/
... but still worth going through. The section on Text files is most applicable here.

For your question, the main thing to bear in mind is that reading from a file in C++ can be almost the same as getting input from cin.

First open the file, then read the first integer.
Then repeat that many times (use a for loop), read three integers and do the required processing.
You should add error checking, particularly to confirm that the file is opened properly

Last edited on
Topic archived. No new replies allowed.