Program to calculate power of a number without using math.h | Learn Programming in C

preview_player
Показать описание


Рекомендации по теме
Комментарии
Автор

what do I do if I want to calculate negative number in variable b?

kylest
Автор

/*To input base and exponent .Calculate the result and print the result without using pow() function*/
#include<stdio.h>
int main()
{
int b, e, i, prod=1;
printf("Enter the base and exponent value respectively:\n");
scanf("%d%d", &b, &e);
for(i=1;i<=e;i++)
{
prod*=b;
}
printf("%d", prod);
return 0;
}

muzicArt
welcome to shbcf.ru