Sunday 21 January 2018

Program for Prime Number


Program for Prime Number
#include<stdio.h>
#include<conio.h>
main()
{
int n,a,j,i,t=0;
clrscr();
printf("enter the value of n");
scanf("%d",&n);
for(j=1;j<=n;j++)
{
t=0;
for(i=2;i<=j-1;i++)
{
a=j%i;
if(a==0)
{
t=t+1;

}
}
if(t==0)
printf("%d\n",j);
}

getch();
}�

0 comments:

Post a Comment