Here's my problem: Write a program that generates integers between 1 and 100 and stores 25 even integers into an integer array named intList then displays the array on the screen AND a data file called evenIntegers.txt.
Here's what I have so far:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream fout;
int intList[25];
fout.open("C:\\classdata\\evenintegers.txt");
for(int i = 1; i <= 100; i++){
if(i % 2 == 0) {
cout << i <<" ";
fout << i <<" ";
}
}
fout.close();
return 0;
}
I am getting all the even numbers from 1- 100, but how do I stick 25 in the array AND displays the array on the screen AND a data file called evenIntegers.txt. I am sick so it's hard for me to concentrate on solving this.
Aucun commentaire:
Enregistrer un commentaire