Kullanıcıdan girilen sayının asal olup olmadığını bulan C kodları

06:48 0 Comments

#include <stdio.h>
#include <conio.h>
void main() {

// asal sayı hesaplama programı

int sayi;
int sayac = 0;
printf("Lürfen bir sayı giriniz");
scanf_s("%d", &sayi);

for (int i = 1; i <= sayi; i++){
if (sayi%i == 0){
sayac = sayac + 1;
}
}

if (sayac > 2){
printf("%d sayısı asal değildir ", sayi);
}
else {
printf("%d sayısı asaldir ", sayi);
}
_getch();

}

erdem

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google

0 yorum: