C Saved Program: gifted-city

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#include <stdio.h>
int main()
{
    int low, high, i, flag;
    printf("Enter two numbers(intervals): \n");
    scanf("%d %d", &low, &high);

    printf("Prime numbers between %d and %d are: \n", low, high);

    while (low < high)
    {
        flag = 0;

        for(i = 2; i <= low/2; ++i)
        {
            if(low % i == 0)
            {
                flag = 1;
                break;
            }
        }

        if (flag == 0)
            printf("%d ", low);

        ++low;
    }

    return 0;
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs