First of all, let me exaplain that I only really know python. I thought I would give c++ a try and since then (about two days ago), I have read a few tutorials and have made a guess number game. I thought I would be able to rewrite one of my python programs, a prime number generator into c++, I know I probably did it horribly wrong, but I really do appreciate all help. Heres the code:
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int counter = 3;
double sq = 0;
int i = 0;
int prime = 1;
cout << "2" << endl;
for(;;)
{
prime = 1;
sq = (sqrt(counter)) + 1;
for(i = 1; i <= sq; i++)
{
if(counter % 2L)
{
prime = 2;
break;
}
}
if(prime == 1)
{
cout << counter << endl;
counter += 2;
}
else if(prime == 2)
counter += 2;
}
}