Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

task of nth power without math.h

$
0
0
#include<iostream>
using namespace std;

void main()
{
	double a,d;
	int b;
	cout<<"*********nth square********"<<endl<<endl;
	cout<<"enter number for which power is to be taken"<<endl;
	cin>>a;
	cout<<"enter the power you want to take for the entered number"<<endl;
	cin>>b;
	
	if(b==2)
	{
		d=a*a;
		cout<<"square of entered number = "<<d<<endl;
	}
	else if(b==3)
	{
		d=a*a*a;
		cout<<"cube is "<<d<<endl;
	}
}



i want that that it should work as "a" should be multiplied by it self as many times as
"b" is entered by the user. how can i do it, i cant understand what codition or loop to use here??

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>