Created
March 30, 2021 07:24
-
-
Save jagdish4501/3073b5854d6bcbb22b7f339352d816a0 to your computer and use it in GitHub Desktop.
Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.
This file contains 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> | |
int main() | |
{ | |
int a, b, c, pow = 1; | |
printf("enter the value of a, b"); | |
scanf("%d%d", &a, &b); | |
for (c = 1; c <= b; c++) | |
{ | |
pow = pow * a; | |
} | |
printf("pow(%d,%d)=%d", a, b, pow); | |
} | |
--------->>>>> | |
//second methode using <math.h> header file | |
#include <stdio.h> | |
#include <math.h> | |
int main() | |
{ | |
int a, b, c; | |
printf("enter the number a & b "); | |
scanf("%d : %d", &a, &b); | |
c = pow(a, b); | |
// c=a^b or pow(a,b)=a^b | |
printf("c=%d", c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment