Write a program that count total prime numbers from 1 to n.

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

void main()
{
    int n,k=0;
    clrscr();
    cout<<"Enter 1st number, n = ";
    cin>>n;

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

       for(int j=2;j<=t;j++)
          if(i%j==0)
          {
             p=0;
         break;
          }
          if(p==1)
             k++;
    }

    cout<<"Total Prime number = "<<k;
    getch();
}

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