I think I have a hard time understanding the return() statement.

I have to make a program where a user gives the lower limit and upper limit as input.

After that, the program should give all prime numbers that are between those 2 numbers.

A testcase would be:

input:

10

30

output:

A list of all prime numbers between the lower and upper limit.

11

13

17

19

23

29

The part that actually calculates if a number is a prime number has been put into a function is_prime.

What i want the program to do is to return a 1 or 0 based on the value of is_prime which depends on if the function is_prime has found a prime number or not.

```
#include <stdio.h>
int number = 0;
int result = 1;
int is_prime(result)
{
/*Declare variables*/
int testcases = 4;
int N;
int i = 0;
/* implement 4 testcases */
for(N = 0; N < testcases; N++)
{
printf("\n\nVoer een getal in: ");
scanf("%d", &number);
/*Numbers smaller than 2 aren't prime numbers*/
if (number < 2)
{
printf("%d is geen priemgetal", number);
result = 0;
}
else
{
i = 2;
while ((i*i) <= number)
{
/*Checks if number divided by i is an even number*/
if ((number % i) == 0)
{
result = 0;
break;
}
else
{
i += 1;
}
}
/*Determine if number is a prime number based on the value of result*/
if (result == 0)
{
printf("%d is geen priemgetal", number);
}
if (result == 1)
{
printf ("%d is een priemgetal", number);
}
}
}
return result;
}
int main(void)
{
int upper_limit = 0;
int i = 0;
int lower_limit = i;
printf("Upper limit: ");
scanf("%d", &upper_limit);
printf(" lower limit: ");
scanf("%d", &lower_limit);
while (i < upper_limit)
if (is_prime(result))
{
printf("%d", number);
}
else
{
i += 1;
}
return 0;
}
```

This is the nassi-schneiderman diagram that goes with it.

http://img836.imageshack.us/f/primes.gif/

*Edited 6 Years Ago by arnas*: n/a