Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int num,i,j,c;
- printf("please enter the number?\n");
- scanf("%d",&num);
- for (j=1;j<=num;j++){ // count from 1 to NUMBER
- for (i=1,c=0;i<=j;i++){ //check for prime number and initialize c to zero
- if (j%i==0){
- c++;
- }
- }
- if (c==2){
- printf("%d\n",j);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment