Q2 Write a function power (a, b), to calculate the value of a raised to b.

Write a function power (a, b), to calculate the value of a raised to b.

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

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.