Prime numbers are natural numbers greater than 1 that has no positive divisors other than 1 and itself. A number that is not a prime is called composite, except 1 because 1 is considered neither a composite nor prime.

For instance, 7 is a prime because only 1 and 7 can divide it, whereas 6 is a composite because it has the divisors 2 and 3 in addition to 1 and 6.

## C Program to print first 10 prime number

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

int ct=0,n=0,i=1,j=1;
clrscr();
while(n<10)
{
j=1;
ct=0;
while(j<=i)
{
if(i%j==0)
ct++;
j++;
}
if(ct==2)
{
printf("%d ",i);
n++;
}
i++;
}
getch();
}```

## C++ Program to print first 10 prime number

```#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i,j,count=1,b=0;

cout<<“First Ten Prime Numbers are”<<“2”;
for(i=3;i>0;++i)
{
for(j=2;j<=i;++j)
{
if(i%j==0)
b=1;
break;
}
if(b==0)
{
cout<<“n”<<i;
count++;

}
b=0;
if(count==10)
break;
}
getch();
}```

Check out – All CSE Basic Practicals

Thanks for visiting us. Do share us among your friends.

Program to find first 10 prime numbers – Computer Practical
Tagged on:

### One thought on “Program to find first 10 prime numbers – Computer Practical”

• August 4, 2016 at 8:54 pm