how to print all prime number between intervals in c ?

#include<stdio.h>
int main() {
    int low, high, flag;
    int i;
    //take inputs
    printf("enter intervals: ");
    scanf("%d%d", &low, &high);

    // start loop for starting value to ending value
    while(low<high){
        // update value of flag
        flag = 0;
        // ignore value which less the 2
        if(low < 2){
            ++low;
            continue;
        }
        // logic for check prime number
        for(i = 2; i<= low/2; ++i){
            if(low % i == 0){
                flag = 1;
                break;
            }
        }
        if( flag == 0){
            printf("%d\n", low);
        }
        // increment the values
        ++low;
    }
}

.
.
.
.
#technology #cybersecurity #hacking #security #hackingtools  #hackingtips
#kalilinux #linux #macaddress

Comments

Popular posts from this blog

JWT auth