Question
programing langauge c++ 1 Even number Write the function bool isEven(int n) which returns true if n is evenly divisible by 2, false otherwise. Zero
programing langauge c++
1 Even number Write the function bool isEven(int n) which returns true if n is evenly divisible by 2, false otherwise. Zero is taken
to be even.
2 Backwards array
Write the function bool isReversable(int a[], int n) which returns true if reversing the order of the elements in the size-n array a results in an identical array. For example, if [5, 9, 3, 9, 5] is passed in as a, isReversable returns true and if [5, 9, 3, 9, 4] is passed in as a, isReversable returns false.
3 Sum of an array of integers. Write the function int sum(int a[], int n) which returns the sum of the integers in the size-n array a.
4 Product of an array of integers. Write the function int product(int a[], int n) which returns the product of the integers in the size-n array a.
5 Fizz Buzz
Write a function void FizzBuzz(int n) that lists all of the numbers from 1 to n, but replace all numbers divisible by 3 but not divizible by 5 with the word Fizz, replace all numbers divisible by 5 but not divisible by 3 with the word Buzz, and replace all numbers divisible by both 3 and 5 with FizzBuzz. The output for the command FizzBuzz(20) should be as follows:
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 17 Fizz 19 Buzz
1
6 Multiplication table
Write a function void multiTable(int n) to print an n-by-n multiplication table (starting with 1). Each number should be preceded by a tab. The output for the command multiTable(5) should be as follows: 12345
-
2 4 6 8 10
-
3 6 9 12 15
-
4 8 121620
-
5 10152025
7 Greatest Common Divisor
Write a function int gcd(int a, int b) which uses the Euclidean algorithm to return the greatest common divisor of a and b. If youre not familiar with the Euclidean algorithm, google it, as you are required to use the Euclidean algorithm for this problem. You may assume that a b > 0.
8 Prime numbers Write the function bool isPrime(int n) which returns true if n is prime, false otherwise. A number is prime if and
only if it is not divisible by any number smaller than itself and greater than 1. You may assume that n > 1.
programing langauge c++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started