c-programs-basics
We have seen how to find the given number is prime or not earlier. Now we will calculate prime numbers on a given range and print them on the screen.

Display Prime Numbers On a Given Range


#include<stdio.h>
#include<conio.h>
void main()
{

 int n,i,t;
 clrscr();

 printf("\n Enter The Range From 1 to : ");
 scanf("%d",&t);

 printf("\n Prime Numbers in the Range 1-%d :\n\n ",t);
 for(n=1;n<=t;n++)
  {
    for(i=2;i<=n-1;i++)
      {
        if(n%i==0)
          {
            break;
          }
      }

 if(n==i)
  printf(" %d",n);

  }
  getch();

}

Output :

Output-Find-Prime-Numbers-In-Given-Range








  •  Following are the prime numbers from 1-100.

prime-numbers-on-given-range-1-100



















In this way we, we can find prime numbers on given range and display them on the screen.