Pages

Friday, 1 February 2019

PRIME NUMBERS IN BETWEEN MIN AND MAX VALUES

PRIME NUMBER RANGE IN BETWEEN MIN AND MAX VALUES :

// program to illustrate prime numbers range in between min and max values
#include<stdio.h>
#define pf printf
#define sf scanf
void main()
{
 int min,max,n,i,count;
 pf("\nEnter min number:");
 sf("%d",&min);
 pf("\nEnter max number:");
 sf("%d",&max);
 pf("\n Prime numbers are:");
 for(n=min;n<=max;n++)
 {
   i=1,count=0;
   while( i <= n )
    {
      if((n % i == 0) && (n % n == 0))
         count++;
      i++;
    }
   if (count == 2)
     pf("\n%d is a prime number",n);
 }
}

output:

No comments:

Post a Comment

Programs in turboc3 : Files

File Handling in C File Handling concept in C language is used for store a data permanently in computer. Using this concept we can store our...