Hello everyone,
I'm new to C++ and I was going through some example programs from my textbook involving nested ifs inside loops. I took this program straight from my textbook but for some reason I can't get it to compile. It gives me an error saying the exit was not declared in this scope. If anyone can let me know why this is, it would be a great help. Fyi, idk if it matters but im using Eclipse with mingw.
#include <iostream>
#include <process.h>
using namespace std;
int main() {
unsigned long n, j;
cout << "Enter a number: " << flush;
cin >> n;
for (j=2; j <= n/2; j++)
if(n%j == 0){
cout << "It's not prime; divisible by " << j << endl;
exit(0);
}