How would the code for this look like in C ? I did try doing it on javascript but did not know how too loop it. A program that determines if a number that the user has entered is a prime number. The program will continue to ask for numbers until the user enters a value less than 2. This program must be implemented using modules. example :
Enter a number: 4
4 is not a prime number
Enter a number: 5
5 is a prime number
Enter a number: 0
int main()
{
int n, i = 3, count, c;
printf("Enter the number of prime numbers required\n");
scanf("%d",&n);
if ( n >= 1 )
{
printf("First %d prime numbers are :\n",n);
printf("2\n");
}
for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}
return 0;
}