Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save scratchyourbrain/30b4a85a1bbd9243f7fd to your computer and use it in GitHub Desktop.
Save scratchyourbrain/30b4a85a1bbd9243f7fd to your computer and use it in GitHub Desktop.
C program to Calculate the Power of a Number
#include <stdio.h>
int main()
{
int base, exp;
long long int value=1;
printf("Enter base number and exponent respectively: ");
scanf("%d%d", &base, &exp);
while (exp!=0)
{
value*=base;
--exp;
}
printf("Answer = %d", value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment