From 335d81777127a9ea7583b10baa53e91c6299c895 Mon Sep 17 00:00:00 2001 From: Grace-Hephzibah Date: Mon, 24 May 2021 11:20:23 +0530 Subject: [PATCH] Prime-Number --- Prime_Number.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Prime_Number.c diff --git a/Prime_Number.c b/Prime_Number.c new file mode 100644 index 0000000..d4a1e07 --- /dev/null +++ b/Prime_Number.c @@ -0,0 +1,52 @@ +// Prime Numbers between 2 interval + +#include + +int main() +{ + int a,b, check; + int dum = 1; + + printf("Enter the range of values \n"); + printf("The Start : "); + scanf("%d", &a); + printf("The End : "); + scanf("%d", &b); + + printf("\n The Prime Numbers from %d to %d \n", a, b); + + for (int i = a; i<=b; i++) + { + check = 0; + + if (i <= 1) + continue; + + else if (i == 2) + check = 0; + + else + { + for (int j = 2; j<=(i/2)+1; j++) + { + if (i%j == 0) + { + check = 1; + break; + } + } + } + + if (check == 0) + { + printf("%d\t", i); + dum++; + } + + if (dum%6 == 0) + { + printf("\n"); + dum = 1; + } + } +}