# How Can Write A Program To Find Prime Numbers?

Write a program to find out prime numbers between 1to500
thanked the writer.
#include<iostream.h>
#include<conio.h>
void main()
{
int  n;
clrscr();
cout<<"Enter any one number:";
cin>>n;
prime(n);
getch();
}
int prime(int x)
{
for(I=2;I<x/2;I++)
{
if(x%I==0)
{
return x;
}
return x;
}
}

thanked the writer.
Following is the code. Here you just have to enter the number "n" and then the program will find the prime numbers from 1 till n.
Main()
{
int n,I=1,j,c;  // defining all variables
clrscr();  // clear screen

printf("Enter Number ");
scanf("%d",&n); //enter the number

printf("Prime Numbers Are Following from 1 to %d", &n);

//This loop is for checking the number

while( I <= n)
{
c = 0;
for(j=1;j<=I;j++)
{
if(I%j==0)
c++; // if number is not prime then c = 1.
}
if(c==0) // if the number is prime then show the number
printf("%d",I)
I++;
}

}
thanked the writer.
//program to generate prime numbers

#include
#include

void main()

{int prime_no,remainder,divider;

for(prime_no=2;prime_no
thanked the writer.
#include
main()
{
int a,c=0,I,n;
printf("enter a no:");
scanf("%d",&a);
for(I=1;I
thanked the writer.
#include
main()
{
int n,I=1,j,c;
clrscr();
printf("Enter the range");
scanf("%d",&n);
printf("Prime Numbers are:");
while(I
thanked the writer.