C++ program to calculate a to the power b without using power function

Sunday, April 4th, 2010

Write a C++ program to calculate a to the power b without using power function.

#include<iostream.h>
#include<conio.h>
void main()
{
	int a,b,i,temp=1;
	clrscr();
	cout<<"Enter number for operation";
	cin>>a>>b;
	for(i=1;i<=b;i++)
	{
		temp=temp*a;
	}
	cout<<endl<<"Result are:: "<<temp;
	getch();
}
Avatar Image

Author Name :
Ranjith

Total : 1 Comment


One Response to “C++ program to calculate a to the power b without using power function”

  1. dynamoblaze says:

    Sir, this gives a^b+1

Leave a Reply

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup