| Homework 10Details
- (6 points) Given that there is a function pow(a,b)
that computes ab, write a function
int sumCubes(int n) that uses a for loop to compute
13+23+33+...+n3.
-
(3 points) Write a function boolean isSet(int n,int b)
that returns true if the bth bit of n is 1
and false otherwise. We order bits from right to left,
so isSet(n,0) determines whether or not n is odd or even.
It might help you to know that there is an operator a>>b that shifts
a to the right by b bits, discarding the low order bits.
For instance, 8 >> 2 gives you 2 and 15 >> 2 gives you 3.
|
|
|