RUN


We can easily find out the power of a number by using pow() function of <math.h> library.

It takes two arguments base and exponent and gives the result.

Example:

  1. Input the base: 23

    Input the exponent: 4

    Answer: 279841

  2. Input the base: 9

    Input the exponent: -3

    Answer: 0.00137174

# Algorithm

  1. Take base and exponent as input from user.
  2. Result = pow(base,exponent).
  3. Print the result

Code:

// Program to find power of any number

#include <iostream>
#include<math.h>
using namespace std;

int main(){
  float base, expo;
  cout << "Input the base: ";
  cin >> base;
  cout << "Input the exponent: ";
  cin >> expo;
  cout << "Answer: " << pow(base, expo);
}

Report Error/ Suggestion

Related Posts:





CopyRight © 2020

CopyRight © 2020