c program to find power of a number without using pow function
- # include < stdio . h >
- # include < string . h >
- # include < conio . h >
- # include < math >
- # include < stdlib >
- int Pow ( int a , int b ) {
- int power = 1 , i ;
- for ( i = 1 ; i < = b ; + + i ) {
- power = power * a ;
- }
- return power ;
- }
- int main ( ) {
- long long int base , exponent ;
- printf ( " enter Base : " ) ;
- scanf ( " % d " , & base ) ;
- printf ( " enter Power : " ) ;
- scanf ( " % d " , & exponent ) ;
- printf ( " % d ^ % d = % d " , base , exponent , Pow ( base , exponent ) ) ;
- }
Comments
Post a Comment