Question: Using basic C language, write a program that takes two numbers n and r as integers (entered by the user). Then your code uses a

Using basic C language, write a program that takes two numbers

n

and

r

as integers (entered by the user). Then your code uses a

loop to compute the nth generalized harmonic number of order

r

, which is defined by the following formula:

H

(

n, r

) =

1

1

r

+

1

2

r

+

...

+

1

n

r

Sample run:

Enter

n

and

r

separated by space:

3 2

H(3,2) is approximately 1

.

36

Thank you!

1) You may need to use the predefined function

pow

. As we have seen, when you use a C function, you may

need to include the library in which that function is defined...

2) when you divide an integer by integer, you get an integer. For example:

float x = 3/2;

printf (%.2f, x);

This code prints 1.00 (not 1.50)

However, if you do what is called

data type cast

(or type conversion) as shown below, you will get 1.50:

float x = (float) 3/2;

printf (%.2f, x);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!