Friday, March 25, 2011

C++ Programming Lab - Program 1

/*      Raising a number n to a power p */

#include <iostream.h>

void power(double n,int p)

{

double pow=1;

int i=1;

while (i<=p)

{

pow=pow*n;

i=i+1;

}

cout<<"N Raise to power p="<<pow;

}

void main

{

double n;

int p;

cout<<"enter any no";

cin>>n;

cout<<"Enter power (p):";

cin>>p;

power(n,p);

 

}

No comments :

Post a Comment