Write the function summation which takes two parameters, start and end. summation adds all the integers from start to end, inclusive, together and returns the sum. Put the necessary blocks in the correct order.
int summation(int start, int end) {
---
void summation(int start, int end) { #distractor
---
int summation() { #distractor
---
int n = start;
---
int sum = 0;
---
int sum = start; #distractor
---
while (n <= end) {
---
while (n < end) { #paired
---
sum = sum + n;
---
n++;
---
}
---
return sum;
---
return n; #distractor
---
}
Write the function reverseNumber which takes num as a parameter and returns num but with its digits reversed. For example, reverseNumber (1324) returns 4231. Put the necessary blocks in the correct order, with reverse declared first, then temp, and lastly remainder.
Write the function printStars. It that takes in an integer and should print * that many times, all on one line (no endls). If the function is passed 3 it should print ***. If it is passed 8 it should print ********. An argument of less than 1 should print no stars.
Write a function collatz that accepts an integer and prints the Collatz sequence for that number. Print a space after each number in the sequence, including the final 1.
Write a function findPower that takes a single integer X as a parameter; you can assume it will be greater than 1. Find the largest power of X that is less than or equal to 1000 and return that value.
Your loop may go one step too far. You will need to return the value that came before the first one that was too large. You can use a variable to keep track of the last valid power or calculate it from the βone step too bigβ value.
This problem is best solved with nested loops. First just worry about using a loop to print one row of *s. Then add a loop around that one to repeat that row size number of times.
Write the function printTriangle that has an integer parameter size. Print a triangle of *βs that is size tall and wide that looks like these examples. An input of 3 should produce:
Write the function printTriangle2 that has an integer parameter size. Print a triangle of *βs that is size tall and wide that looks like these examples. An input of 3 should produce:
How does the number of spaces relate to the size and the row number? If the size is 5, how many spaces are there at the start of row 1? How many at the start of row 2?