the following program displays the pth prime number.....but the program is not working ......plz help

#include<stdio.h>
#include<conio.h>
void main()
{
long int a=0,n=0,i=2,j , p ;
printf("insert the number") ;
scanf("%ld",&p);
while(n!= p-1)
{
for(j=2 ; j<=i-1 ; j++)
{
if(i%j == 0)
{
a==1 ;
break ;
}

}
if (a==1)
{
n=n+1 ;
a=0 ;
}

i=i+1  ;
}
printf("%ld",i);
getch() ;
}

Recommended Answers

All 2 Replies

Hello sudipan007...
a=1 and not a==1.

if(i%j==0)
{a=1;
}

Use CODE Tags -- they are described all over this site. Including on the background of the box in which you typed your question.

Please read the following information:
formatting
void main()
pausing a program

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.