Q3 Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.

Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.

Program: 96

Two numbers are entered through the keyboard. Write a c program to find the value of one number raised to the power of another.

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
    int a, b, c, x;

    printf("Enter the value of a: ");
    scanf("%d", &a);
    printf("Enter the value of b: ");
    scanf("%d", &b);
    //second method using <math.h>
    //c = pow(a,b);
    c = 1;
    x = b;
    while(b!=0)
    {
        c = c * a;
        b = b - 1;
    }
    printf("%d raised to the power %d: %d",a,x,c);
}

Output:

 Enter the value of a: 2
 Enter the value of b: 3
 2 raised to the power 3: 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.