how to check prime number in c ?

#include<stdio.h>
int main() {
    int num, i, flag = 0;
    printf("enter number");
    scanf("%d", &num);
    for(i = 2; i<= num/2; ++i){
        if(num%i == 0){
            flag = 1;
            break;
        }
    }
    if(num == 1) {
        printf("number is not prime");
    }else {
        if(flag == 0){
            printf("%d number is prime number", num);
        } else{
            printf("%d number is not a prime number", num);
        }
    }
}
.
.
.
.
#technology #cybersecurity #hacking #security #hackingtools  #hackingtips
#kalilinux #linux #macaddress

Comments

Popular posts from this blog

JWT auth