My code is supposed to take numbers from an .txt file, assign them variables, print out the numbers and THEN if the number is less than 25, add them up according to parity.
So, if the list of numbers is 1,2,3,4,5
It'll output: 1 2 3 4 5
Sum of even numbers: 6
Sum of odd numbers: 9
And, it needs to disregard any number larger than 25, not add it to either total and stop the loop when it gets to it.
Any help? Here's what I have so far
[#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int num1, num2, num3, num4, num5, num6, num7, num8; //Each number in the file
ifstream infile;
int eventot=0, oddtot=0; //Total counters for even and odd numbers
infile.open("numlist.txt"); //Opens the text file with numbers
infile>>num1>>num2>>num3>>num4>>num5>>num6>>num7>>num8; //Assigns numbers in list
cout<<num1<<" "<<num2<<" "<<num3<<" "
<<num4<<" "<<num5<<" "<<num6
<<" "<<num7<<" "<<num8<<endl; //Echos numbers in list to output screen
infile.close(); //Force closes the file
while (infile)
{
if(
}
return 0;
}
]