Program in C to find the prime number up to given number.
#include<stdio.h> #include<conio.h> void main() { int i,n,n1,p; printf("Enter a no.:-"); scanf("%d",&n1); printf("prime no.="); for(n=1;n<=n1;n++) { for(p=1,i=2;i<n;i++) { if(n%i==0) { p=0; break; } } if(p==1) printf("%3d ",n); } getch(); }
0 Comments