- #1
- 50
- 1
Homework Statement
So, I'm getting two blocks of zeroes in my console output from this program. After much effort (and stack exchange) I'm still unable to get it working. Could someone point me to a solution?
Mod note: Added code tags
Homework Equations
C:
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
using namespace std;
vector<int> intList(105);
vector<int> multiplesOfTwo(105);
int i;
int z;
int prime = 2;
void createMultipleTwoList()
{
for (z = 2; z <= 100; z++)
{
if (z % 2 == 0)
{
multiplesOfTwo.push_back(z);
return;
}
else
{
return;
}
}
}
void createIntList()
{
for (i = 1; i <= 100;i++)
{
intList.push_back(i);
}
}
int main()
{
int number;
int prime;
for (;;) {
int numberOfPrimes;
cout << "Please enter the number of primes to be printed: ";
cin >> numberOfPrimes;
if (numberOfPrimes <= 100 && numberOfPrimes >= 1) {
createMultipleTwoList;
createIntList;
for (i = 0; i <= 100; i++)
{
cout << multiplesOfTwo[ i] << " ";
}
cout << endl << endl << endl << endl;
for (i = 0; i <= 100; i++)
{
cout << intList[ i] << " ";
}
break;
}
else {
cout << "Please enter a valid integer" << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
}
}
cout << endl;
system("pause");
return 0;
}
The Attempt at a Solution
Last edited by a moderator: