Created
January 4, 2018 10:43
-
-
Save rizwansoaib/b54625b3dc922f81b1d08123fb39010e to your computer and use it in GitHub Desktop.
Find power in c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void power(int x,int y) | |
{ | |
int i=1; | |
int j=x; | |
if (y!=0) | |
{ | |
for(i; i<y; i++) | |
{ | |
x=j*x; | |
} | |
printf("%d",x); | |
} | |
if (y==0) | |
printf("1"); | |
} | |
void main() | |
{ | |
int x,y; | |
printf("Enter base and power e.g. 2^3 , 2 3 \n"); | |
scanf("%d%d",&x,&y); | |
power(x,y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find power in c languages