so my hw problem asks to write a C++ program to read integers from a file into an array. Assuming that the max number of integers that can be read from a file is 50. Read integers from the file into positions in the array starting with subscript 1 and continue reading integers until an end of the file conditions is encountered. The integers are found in the file "numbers.dat"
The program should display the entire list on screen
then display the numbers that appear in the "odd" position in the list (subscripts 1, 3, 5 etc)
then display the numbers that appear in the "even" position in the list
(subsctipts 2, 4, 6 etc)
The only thing I got was making the program display the entire list.
Here is what my program looks like
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
can anyone please help me.
I've tried asking the tutoring center at my school, friends but havent gotten much help.asking my professor is out of the picture...we only see him once a week and he doesn't go over hws...
Thank you for the reply but can you give/show me an example?
I'm really sorry, but I just started programming and I'm not that good with terminology.
I am more of a "see and learn type" if that makes sense
#include <iostream>
usingnamespace std;
const in SIZE = 10;
int main()
{
int anArray[SIZE];
cout << "\nEnter 10 numbers:\n";
for (int i = 0; i < SIZE; i ++)
{
cin >> anArray[i];
}
cout << "Here are the numbers in the array: "for (int i = 0; i < SIZE; i++)
{
cout << anArray[i];
}
return 0;
}
Thanks for the reply but the problem I'm having has to do with is putting numbers into an array from a dat file not a user input.
I can't seem to put the numbers from the dat file into an array and give it a position at the same time