1. ## newline loop

Code:
```#include <stdio.h>
#include <math.h>

int isprime(int n);

int main(void)
{
int i;
int count=1;
printf( "The prime numbers from 1 to 1000 are \n" );
for ( i = 2;i < 1000;i++){
if (isprime(i) && count%10!=0)
printf("%d\t",i);
count++;
if (isprime(i) && count%10==0)
printf("%d\n",i);
count++;
}}
int isprime( int n )
{
int sroot = sqrt(n);
int i;
for ( i = 2;i <= sroot;i++){
if (n % i == 0)
{return 0;}
}
return 1;
}```
i want a newline to be created after every 10th prime number and the if statements for int count do not work. Suggestions? 2. count % 10 can give you from 0-9 only.
You need count % 11.
And don't just tell it's not working. How it's not working!?

You don't need to test twice.
If count variable is supposed to keep track of number of prime printed, it should start from zero. Isn't it? Code:
```count = 0;
for ( i = 2;i < 1000;i++){
if (isprime(i)) {
printf("%d",i);
count++;
}
if ( count%11 ==0)  {
putchar('\n');
} else {
putchar('\t');
}
}
printf("%d primes!\n",count);``` 3. Code:
```	if (isprime(i) && count%10!=0) {
printf("%d\t",i);
count++;
}
if (isprime(i) && count%10==0) {
printf("%d\n",i);
count++;
}```
You need braces around those statements. Without them, only the printfs get put inside the if block, and you do count++ twice per loop. Considering you start count at 1, you then go to 3, 5, 7, 9, 11, etc, skipping every multiple of 10. A better solution would be to keep common code out of the if statements, and to use an else instead of you strange two-if setup:
Code:
```if (isprime(i)) {
if (count % 10) {  // count is not a multiple of 10, print a tab
printf("%d\t", i);
}
else {  // count is a multiple of 10, print a new line
printf("%d\n", i);
}
count++;  // only increment count once
}``` Popular pages Recent additions loop, newline, prime 