Header Ad

C++ program to find out the exponent of given number

In this post, we will write a C++ program to find out the exponent of a given number. the first user will enter the base value of the number and the value of the power of the number. after that program will print the desired result on the output screen.

C++ program to find out the exponent of given number


C++ program to find out the exponent of a given number.

#include<iostream>
#include<conio.h>

int main()
{
    system("cls");

    int i,b,p;
    double res;

    std::cout<<"Enter the base of the number = ";
    std::cin>>b;
    std::cout<<"Enter the power of the number = ";
    std::cin>>p;

    res = 1;
    for(i=1;i<=p;i++)
    {
        res = res*b;
    }

    std::cout<<"The result is = "<<res;

    getch();
    return 0;
}



Output

Enter the base of the number = 5
Enter the power of the number = 4
The result is = 625

Post a Comment

0 Comments