void countUp(int n) { . . }
NOTE: void means that function does not return a value.
IMPORTANT: For each problem you MUST write a main program that tests your function by plugging one or more values into it. Example for problem 1 below:
void countUp(int n) { .#statements that make up the body of the function . . } int main() { countUp(5); }Write, save, and run program file f.c. It should contain a definition for the function void countUp(int n). The function should print the integers from 1 up to the value n. For instance if the main program calls countUp(5), the function should print:
This function does not return a value. You may assume that the argument is a positive integer.
Write, save, and run program file
f.c.
It should contain a definition for the function
void countDown(int n).
The function should print integers from n down to 1.
For instance if the main program calls
countDown(4), the function should print:
4
3
2
1
This function does not return a value. You may assume that the argument is a positive integer.
Write, save, and run program file f.c. It should contain a definition for the function int doubled(double amt,double rate). Parameter amt will hold the initial amount of the investment. Parameter rate will hold the decimal equivalent of the interest rate (0.05 for an interest rate of 5%). The function should compute and return the number of years it will take until the investment has more than doubled.
Write, save, and run program file f.c. It should contain the definition for the function int addUp(int n). This function adds consecutive positive integers, starting at 1 and going up to parameter n: 1+2+3+...+n. It should return the value of the sum.
You may assume that argument in n is a positive integer.
Write, save, and run program file f.c. It should contain the definition for the function int overTheTop(int sumCutOff). This function adds consecutive positive integers 1, 2, 3, ... into the sum until the sum goes over the sumCutOff value. The function should should return the last number added into the sum.
You may assume that argument in sumCutOff is a positive integer.
Write, save, and run program file f.c. It should contain the definition for the function int sumOdds(int cutoff). This function adds consecutive positive odd numbers 1, 3, 5, ... into the sum so long as the numbers are less than the cutoff value. The function should return the sum of these odd numbers.
You may assume that argument in cutoff is a positive integer.
Write, save, and run program file f.c. It should contain the definition for the function int overTheTop(int sumCutOff). This function adds consecutive positive odd numbers 1, 3, 5, ... into the sum until the sum becomes larger than the sumCutOff. The function should return the last odd number added into the sum.
You may assume that the argument in sumCutOff is a positive integer.
Write, save, and run program file f.c. It should contain the definition for the function int square(int n). This function finds the sum of the first n positive odd numbers. That is, the function adds positive odd numbers 1, 3, 5, ... into the sum until the n-th odd number has been added in. The function should return the sum of these numbers.
You may assume that the argument in n is a positive integer.
Write, save, and run program file f.c. It should contain the definition for the function int sumTri(int cutOff). The function adds Tri numbers into the sum. Tri numbers are every third number: 1, 4, 7, 10, .... The function adds consecutive Tri numbers 1, 4, 7, ... into the sum so long as the Tri number is less than the cutOff. The function returns the sum of these numbers.
You may assume that the cutOff is a positive integer.
Write, save, and run program file f.c. It should contain a definition for the function int sumEven(int n). The function adds even numbers 2, 4, 6, ... into the sum until the n-th even number has been added in. The function returns the sum of these numbers.
Write, save, and run program file
f.c.
It should contain a definition for the function
int myStrlen(char *s).
The function takes a string as a plug-in value and returns the length of
the string. Note: the length does not count the 0 at the end, just the
characters before the 0. It is WRONG to use the built-in function,
strlen
to find the length.