Monday 19 August 2013

Lecture 151

Lecture 151

//Procedures and Functions
//Code:
#include <iostream>
#include <conio.h>
using namespace std;
int pow(int,int);
int pow1(int,int,int);  // Prototype
main ()
{
  int number = 0;
  int power = 0;
  // Getting the input from the user
  cout << " Please enter the number ";
  cin>> number;
  cout << " Please enter the power number ";
  cin>> power;
  cout << "\n The Power number is : "<<pow(number,power);
  getch();
  return 0;
}
int pow(int n,int p)
{
   int n1=n;
   return pow1(n,p,n1);
 
}
int pow1(int n,int p,int n1)// It is a loop(Recursive call)
{
    
     if(p==1)
        return n1;
       n1=n1*n;
       p = p-1;
    return pow1(n,p,n1);
 
}

Output: