Skip to content

Commit

Permalink
Merge pull request #14 from Grace-Hephzibah/Prime-Number
Browse files Browse the repository at this point in the history
Prime-Number
  • Loading branch information
unnati914 authored May 24, 2021
2 parents e400b09 + 335d817 commit 232e85b
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Prime_Number.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Prime Numbers between 2 interval

#include<stdio.h>

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;
}
}
}

0 comments on commit 232e85b

Please sign in to comment.