Welcome

Hi! This blog is for beginners of c++ and java .You can check and pick codes for your programming assignments. This will also help you to understand the concepts of these programming languages. Its all about programming.

Functions Basic

Thursday, May 19, 2011

#include <iostream.h>

long int power (int,int);
int main ()
{
    int a;
    int b;
    cout <<"Enter Base Value : ";
    cin >> a;
    cout <<"\nEnter Exponent Value : ";
    cin >> b;
    cout << power (a,b);
    return 0;
}
long int power (int base,int exp)
{
    int counter=1;
    int product=base;
    while (counter<exp)
    {
        product=product*base;
        counter++;
    }
    return product;
}