Write a program that print all prime numbers from 1 to n.

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
    int n,i,j,p,t,k=1;
    clrscr();
    printf("Enter any number, n = ");
    scanf("%d",&n);

    for(i=2;i<=n;i++)
    {
       p=1;
       t=sqrt(i);

       for(j=2;j<=t;j++)
          if(i%j==0)
          {
             p=0;
         break;
          }
       if(p==1)
       {
          printf("\n%d Prime number = %d",k,i);
          k++;
       }
    }

    getch();
}


///////////////////////////////////////////////////////////////////////////
Copy & paste this code in your TC & run, then you will get output.......
If you have any problem please comment below.........