ab_tanjir

Untitled

Sep 27th, 2019
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int isprime(num){
  5.     int j, flag;
  6.     flag = 0;
  7.  
  8.     if (num <= 1){
  9.         return 0;
  10.     }
  11.  
  12.     for (j = 2; j <= num / 2; j++){
  13.         if ((num % j) == 0){
  14.             flag = 1;
  15.             break;
  16.         }
  17.     }
  18.  
  19.     if(flag == 0){
  20.         return 1;
  21.     }else{
  22.         return 0;
  23.     }
  24. }
  25.  
  26. int main(){
  27.     int num1, num2, i;
  28.     printf("Enter two number");
  29.     scanf("%d", &num1);
  30.     scanf("%d", &num2);
  31.  
  32.     for (num1; num1<=num2; num1++){
  33.         if(isprime(num1) == 1){
  34.             printf(" %d ", num1);
  35.         }
  36.     }
  37.  
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment