Forumunuz.Com

Forumunuz.Com (https://www.forumunuz.com/)
-   Bilgisayar ve Donanımı (https://www.forumunuz.com/bilgisayar-ve-donanimi/)
-   -   Manuel pow Fonksiyonu CPP (https://www.forumunuz.com/bilgisayar-ve-donanimi/15871-manuel-pow-fonksiyonu-cpp.html)

Asrevya 23 Mart 2015 16:53

Manuel pow Fonksiyonu CPP
 

C de bildiğimiz gibi kuvvet alan bir math.h kütüphanesi fonksiyonu bulunmaktadir. hatta ismi de pow() dur. Ancak illa math.h ‘a ihtiyacımız yok bu fonk. için kendimiz gayet rahat bir şekilde tanımlayabiliriz. Nasıl mı? işte kodlar aşağıda :





#include <stdio.h>
int integerPower(int,int);
void main()
{
int base,exponent;
printf(“enter the base : “);
scanf(“%d”,&base);
printf(”
enter the exponent :”);
scanf(“%d”,&exponent);
printf(“%d to the power %d is equal to %d”,base,exponent,integerPower(base,exponent));
}
int integerPower(int b,int e)
{
int result=1;
while(e>=1)
{
result=result*b;
e-=1;
}
return result;
}


Kaynak: Doğu Akdeniz Univ. CSIT Labworks
belgesi-424




Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 19:11.

Powered by vBulletin® Version 3.8.9   Copyright ©2000 - 2026, vBulletin Solutions, Inc.

Site kurucuları: Damla ve Meltem