Program: 123
Write a function power (a, b) in c language, to calculate the value of a raised to b.
#include<stdio.h> #include<conio.h> #include<math.h> int power(int a, int b); int main() { int a, b, res; printf("Enter a: "); scanf("%d", &a); printf("Enter b: "); scanf("%d", &b); res = power(a, b); printf("Result: %d", res); } int power(int a, int b) { int x; x = pow(a, b); return x; }
Output:
Enter a: 2
Enter b: 3
Result: 8
Leave a Comment