Skip to content

Commit

Permalink
Prime-Number
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace-Hephzibah committed May 24, 2021
1 parent e400b09 commit 335d817
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 335d817

Please sign in to comment.