pSkpt

Asal mi değil mi

Apr 23rd, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. main(){
  4.  
  5. int sayi;
  6. int basla = 2;
  7. int asalmi;
  8.  
  9. printf("Sayiyi giriniz : ");
  10. scanf("%d",&sayi);
  11.  
  12. asalmi = 1;
  13.  
  14. while(basla < sayi){
  15.    
  16.     if(sayi % basla == 0){
  17.         asalmi = 0;
  18.        
  19.     }
  20.    
  21.     basla++;
  22.    
  23. }
  24.  
  25. if (asalmi == 1){
  26.     printf("%d sayisi asaldir.",sayi);
  27. }else{
  28.     printf("%d sayisi asal degildir.",sayi);
  29. }
  30.  
  31.  
  32. getchar(); 
  33.    
  34. }
Advertisement
Add Comment
Please, Sign In to add comment