Program Description:
In this program we are going to find out all the prime numbers between a given range and count the number of prime number in it.
Source Code:
//prime number on a given range
#include<stdio.h>
int main()
{
int r,l,u,i,j,n,p=0;
printf("Enter the lower limit:");
scanf("%d",&l);
printf("Enter the upper limit:");
scanf("%d",&u);
printf("\nTHe Prime Numbers are as follow:\n");
for(i=l;i<=u;i++)
{
r=0;
for(n=1;n<=i;n++)
if(i%n==0)
r=r+1;
if(r==2)
{
printf("%d\n",i);
p=p+1;
}
}
printf("\nIn between %d and %d there are %d prime numbers",l,u,p);
printf("\nTHANK YOU");
}
Output:
If you have any query feel free to contact us😊😊
0 Comments