Search
 
SCRIPT & CODE EXAMPLE
 

CPP

power of number

double Pow(double x, int n) 
{
  double ans=1.0;
  while(d>0)
  {
    if(d&1==1)
      ans*=x;
    d>>=1;
    x*=x;
  }
  return ans;
}
Comment

power of a number

#include <iostream>
using namespace std;

long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}

int main()
{
    long long x = 5;
    long long y = 16;
    
    cout << "Power is " << binpow(x, y);
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: C++, for-loop over an array array 
Cpp :: doubly linked list in cpp 
Cpp :: Convert a hexadecimal number into decimal c++ 
Cpp :: C++ code for Dijkstra’s Algorithm 
Cpp :: how to change colour image to grey in opencv c++ 
Cpp :: c++ base constructor 
Cpp :: c++ replace 
Cpp :: what is meant by pragma once in c++ 
Cpp :: double to float c++ 
Cpp :: c++ initialize static variable 
Cpp :: print hello world in c++ 
Cpp :: c ++ splitlines 
Cpp :: size() in c++ SET 
Cpp :: vector iterating 
Cpp :: difference between --a and a-- c++ 
Cpp :: map count function c++ 
Cpp :: length of a string c++ 
Cpp :: vector size 
Cpp :: c++ find index of all occurrences in string 
Cpp :: how to make dictionary of numbers in c++ 
Cpp :: User defined functions and variables in C++ programming 
Cpp :: adddynamic ue4 c++ 
Cpp :: What is a ~ in c++ 
Cpp :: balanced parentheses 
Cpp :: Reverse a linked list geeksforgeeks in c++ 
Cpp :: std::future 
Cpp :: C++ program to print all possible substrings of a given string 
Cpp :: c++ memory address 
Cpp :: free a pointer c++ 
Cpp :: fractional knapsack problem 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =