Wednesday 14 August 2013

Lecture 145

Lecture 145
//Procedures and Functions
//Code:
#include <iostream>
#include <conio.h>
using namespace std;
int pow(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;
   while(p!=0)
   {
     p = p-1;
     if(p==0)
          break;
     n1=n1*n;
   }
   return n1;
  
}
Output: