PRIME NUMBERS
Code :
#include<stdio.h>
int main()
{
int s, j, i, no_prime = 0, n;
printf("========================================\n");
printf("\t PRIME NUMBERS\n");
printf("========================================\n");
printf("Enter lower limit : ");
scanf("%d", &s);
printf("Enter upper limit : ");
scanf("%d", &n);
printf("\n");
if(s < 2)
{
s = 1;
}
printf("All Prime number between %d and %d are,\n\n", s, n);
for(i=s; i<=n; i++)
{
no_prime = 0;
for(j=2; j<i; j++)
{
if(i%j == 0)
{
no_prime = 1;
}
}
if(no_prime == 0)
{
printf("%d ", i);
}
}
printf("\n----------------------------------------\n");
return 0;
}
Come again Learn again !
« iCodeBuzz »
No comments:
Post a Comment