October 31st, 2012 10:27 AM
Pretty sure I got the code right, but I am coming up with a different answer than what I was expecting
55 67 458 23 81 33 782 375 528 405 324 950 46 14 864 551 38 167 518 630
The Average from...
October 31st, 2012 10:20 AM
Ok, so the if statements expression is only true if the remainder of the num%3 equals 0. So if there is no remainder than it is a true statement.
October 31st, 2012 10:12 AM
Ok, Now I had friend give me a hint on this next piece for reading every 3rd integer in the input file, but I don't know how to decipher it.
if(num%3==0)
I get that I will need an "if"...
October 31st, 2012 10:07 AM
Whoa... look at me go lol Thanks!
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;
void main()
October 31st, 2012 09:47 AM
Ok I got it =P
total=0;
counter=0;
filein>>num;
while(filein)
{
fileout<<num<<" ";
October 31st, 2012 09:25 AM
This is the only way I could get it to work. Although it is still repeating the last number twice, but it is giving me the average.
#include <iostream>
#include <cmath>
#include <iomanip>...
October 30th, 2012 12:38 PM
Ok I think I see what you are saying now. I will revise my code after my next class. Thank you for being so helpful.
October 30th, 2012 12:27 PM
Ok, then I will try to build it into one loop. Hopefully I got what you were saying this time. I think I understand that I was being redundant.
So with this new build I am getting the average...
October 30th, 2012 12:00 PM
Ok, for the averages of the numbers here is what I am getting in my output file.
55 67 458 23 81 33 782 375 528 405 324 950 46 14 864 551 38 167 518 630 630
For some reason it isn't giving...
October 30th, 2012 11:45 AM
Ok I see what you are saying. Here is my new updated code. I will be moving on to the averages now.
October 29th, 2012 12:07 PM
Awesome thanks! For some reason I am also having trouble keeping the spaces and end line codes.
I got it with:
fileout<<num<<" ";
October 29th, 2012 12:00 PM
Sorry it has been so long for me to reply. rough week...
Here is my updated code
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;
October 22nd, 2012 02:12 PM
can't find the edit button, but I meant to say this is what I have so far. I am stuck on (A) trying to write to the ANSWER.txt file.
October 22nd, 2012 02:07 PM
Hi,
This is my first post here and I am in need with some help(might need a lot) with a lesson my professor has given me to help me understand loops.
Here is an imgur link to my current...