C program to print Prime number series from 1 to n numbers


Program :-

#include<stdio.h>
void main()
{
 int n,j,i,f=1;
 printf("enter the range of the number......!!!!\n");
 scanf("%d",&n);
 if(n>2)
 {
  printf("2\t");
 }
 for(i=3;i<=n;i++)
 {
  for(j=2;j<i;j++)
  {
   if(i%j==0)
   {
    f=0;
    break;
   }
  }
  if(f==1)
  printf("%d\t",i);
  else 
  f=1;
 }
}

Output :-



Share this

Previous
Next Post »

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer