I want to make a program in C in which you are asked to enter numbers until you enter a "0" or a negative number, when this happens the program should show:
I have done practically each paragraph separately, but I do not know how I could put everything in the same program.
#include <stdio.h>
int main()
{
int n, i, flag = 0;
printf("Teclea un numero entero positivo: ");
scanf("%d",&n);
for(i=2; i<=n/2; ++i)
{
if(n%i==0)
{
flag=1;
break;
}
}
if (flag==0)
printf("%d SI es un numero primo.",n);
else
printf("%d NO es un numero primo :(",n);
getch();
return 0;
}