Learn Computer Science programming - C# and C++ Algorithms

 

Power

Calculate a number to the power of a number.

Code
power.zip
File Size: 4231 kb
File Type: zip
Download File

#include <iostream>
#include <string.h>
#include <windows.h>
using namespace std;

int Power (int number, int power)
{
int counter = 0; 
int result = 1;
while (counter++ < power)
result = result * number;
return result;
}

void main()
{
int x;
wcout <<  endl << "*** To the Power of - Calculate 2^10***" << endl;
wcout << "*************************************************" << endl;
long result = Power( 2, 10);
wcout << "The result is :" << result << endl;
cin >> x;
 }