Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n, i, j, isPrime;
- printf("Enter the Limit: ");
- scanf("%d",&n);
- printf("Prime numbers are: ");
- printf("1 ");
- for(i=2; i<=n; i++)
- {
- isPrime=0;
- for(j=2; j<=i/2; j++)
- {
- if(i%j==0)
- {
- isPrime=1;
- break;
- }
- }
- if(isPrime==0 && n!=1)
- printf("%d ",i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement