[Solved] c++ program prints prime number using functions [closed]


Such amazing complexity for a simple problem. You don’t need arrays to do this, not even multi-dimensional arrays.

int main()
{
    int count = 0;
    for (int i = 1; i <= 100; ++i)
    {
        if (is_prime(i))
        {
            cout << i << ' ';
            ++count;
            if (count == 5)
            {
                cout << endl;
                count = 0;
            }
        }
    }
    cout << endl;
}

0

solved c++ program prints prime number using functions [closed]