write a C function which takes natural number nas argument and calculate the sum of the digits raised to the power of the number of digits in n.

1 answer

You need to find n^m where m is the sum of the digits of n.

Step 1:
Find the sum of digits of n.
You could try the following algorithm, either inline or using a function (method):

Let k=n
m=0
do until k<=0
m+=k%10
k/=10
end do

Step 2:
Raise n to the mth power:

result=1
k=m
do until k<=0
result*=n
k--
end do

The answer will be in "result".
But do take care that the result will not overflow. What to do depends on what you have learned.
Similar Questions
  1. WRITE A FUNCTION RULE TO DESCRIBE EACH SITUATION.PLEASE HELP I DO NOT UNDERSTAND THIS AT ALL. The number of pounds p(z)as a
    1. answers icon 3 answers
  2. Natural estimatorsThe random variables Xi are i.i.d. and satisfy E[X2i]=θ. Use a natural estimator to calculate an estimate of
    1. answers icon 2 answers
    1. answers icon 1 answer
    1. answers icon 1 answer
more similar questions