mercredi 1 juin 2022

Programming principles and practice ch 4 exercise [duplicate]

I started to learn to code in C++ and has been reading Programming Principles & Practices Using C++. All is going well until I met Q.10 and Q.11 but I'll just focus on Q.11

Question: Find prime numbers between 1 to 100 and use a vector to store the value

#include <iostream>
using namespace std;
#include <vector>

int main() {
    vector<int> primes;
    for (int i = 0; i<primes.size(), ++i;) {
        if (i%2 != 0) {
            primes.push_back(i);
            cout << primes;
        }
    }
}

When I run the program, there's an error (im pretty sure it's the cout << primes part). I just don't know what's wrong

Aucun commentaire:

Enregistrer un commentaire