//Hi,i need to create programm,which takes the user input,determins how many digits in integer
// and than raise this digit to power,what was entered by user too.
//first function noraml,second one to rais to power recursive. So if user enter number
//234,this is 3 digits,so now need recurcively 3 raise to the power .
// This what i got so far program determins the digits from integer,but does not use power
// Power of size number.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<string>
using namespace std;
typedef long double ld;
int countDigits(int number) {
if (number < 10) {
return 1;
}
int count = 0;
while (number > 0) {
number /= 10;
count++;
}
return count;
}
int place(ld,ld);
// testing the countDigits function
int main() {
int num ;
int result;
int exp;
cout << "enter number: "<<endl;
cin >> num;
cout << "Enter exponent: " << endl;
cin >> exp;
int numDigits = countDigits(num);
cout << num << " has " << numDigits << " digits" << endl;
result = place(numDigits,exp);
cout << result;
return 0;
}int place(ld numDigits,ld exp)
{
if(exp >=10)
{
return
numDigits*(place(numDigits,exp-1));
}
else
return 1;
}
aluhnev 0 Junior Poster in Training
Banfa 597 Posting Pro Featured Poster
tinstaafl 1,176 Posting Maven
aluhnev 0 Junior Poster in Training
tinstaafl 1,176 Posting Maven
aluhnev 0 Junior Poster in Training
aluhnev 0 Junior Poster in Training
tinstaafl 1,176 Posting Maven
Banfa 597 Posting Pro Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.