Kullanıcıdan girilen sayının mükemmel sayı olup olmadığını kontrol eden C programı
#include <stdio.h>#include <conio.h>
void main() {
// Girilen sayının müükemmel sayı olup olmadığı kontrolü
int sayi;
int toplam = 0;
printf("Lürfen bir sayı giriniz");
scanf_s("%d", &sayi);
for (int i = 1; i < sayi; i++){
if (sayi%i==0){
toplam = toplam + i;
}
}
if (toplam == sayi){
printf("bu sayi mukemmel sayidir");
}
else {
printf("bu sayi mukemmel degil ");
}
_getch();
}
0 yorum: