Hello! So here are the instructions:
|Write two seperate programs. The first one will write random data out to a binary file display the sum of every other number. |
The second will read the file generated by the first program and add every other number.
Compare the two sums.
Here is my code so far for the first program:
theStream.open("Numbers.txt", ios::binary | ios::out);
string ranNum = "abcdefghijklmnopqrstuvwxyz";
for( char i : ranNum)
Since characters are technically numbers, can I do this? Also, then how can I display the sum of every other number?
The instructions call for random
data, not iterative. So since you're already using x11 try something like the 'std::random_device' generator.
|display the sum of every other number. |
The way I read that, you would have to determine if the random character is an integer before you consider it for summation.
- std::random_device: http://www.cplusplus.com/reference/random/random_device/
Topic archived. No new replies allowed.