I'm relatively new to C and I am trying to get a program to run. It's a program that lists all primes from 1 - 1000. The way I compile it is by typing gcc Primes.c
into the command line and running it in NppExec.
Code:
#include <stdio.h>
#include <math.h>
int x;
int bool = 1;
int y;
main() {
for (x = 2; x <= 100; x++) {
bool = 1;
for (y = 0; y <= floor(x/2); y++) {
if (x % y == 0) {
bool = 0;
}
}
if (bool == 1) {
printf("%d\n", x);
}
}
}
I type:
NPP_SAVE
CD $(CURRENT_DIRECTORY)
C:\MinGW32\bin\gcc.exe -g "$(FILE_NAME)"
a
into the box and then execute. A window will pop up and say a.exe
has stopped working. Any idea's on how to fix this?