Kullanıcıdan girilen sayının mükemmel sayı olup olmadığını kontrol eden C programı

07:17 0 Comments

#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();

}

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: