Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Power Function in C/C++

#include <cmath> //library for the function 

pow(x,y);

Given two numbers base (x) and exponent (y), pow() function finds x raised to the power of y. 
Comment

exponent of x using c c++

//* exponent or power of x using loop
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int x = 1, power = 0, temp = 0;
    cin >> x >> power;
    temp = x;
    for (int i = 1; i < power; i++)
    {
        x *= temp;
    }
    cout << x << endl;

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: stl in c++ 
Cpp :: C++ sum a vector of digits 
Cpp :: how to grab each character from a string 
Cpp :: oop in cpp 
Cpp :: udo apt install dotnet-sdk-5 permission denied 
Cpp :: c++ check if key exists in map 
Cpp :: how to check char array equality in C++ 
Cpp :: convert wchar_t to to multibyte 
Cpp :: friend function in c++ 
Cpp :: create new node in tree 
Cpp :: Lambda capture as const cpp 
Cpp :: for statement c++ 
Cpp :: how to write int variable c++ 
Cpp :: what is the default include path in ubuntu c++ 
Cpp :: sliding window c++ 
Cpp :: opengl draw house using glut c++ 
Cpp :: how to get last element of set 
Cpp :: how to extract a folder using python 
Cpp :: len in cpp 
Cpp :: what is the time complexitry of std::sort 
Cpp :: shift element to end of vector c++ 
Cpp :: convert single character string to char c++ 
Cpp :: public method 
Cpp :: how to modify 2d array in function c++ 
Cpp :: floyd algorithm 
Cpp :: c++ overloading by ref-qualifiers 
Cpp :: enter items in array until enter is pressed c++ 
Cpp :: C++ Volume of a Cube 
Cpp :: how to make c++ read strlen 
Cpp :: sfml disable message 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =