#include #include using namespace std; ////////////////////////////////////////////////////// // Rules: // The main function contains a bunch of tests for a // set of functions that you are going to write. // Everything in main is commented out because it // won't compile (build) until you write the needed // functions. // // Read the comments in main to see how the code // should work once you add your functions. ////////////////////////////////////////////////////// // YOUR FUNCTIONS HERE // END YOUR FUNCTIONS - DO NOT EDIT MAIN (except to uncomment things to test) int main() { //Add, multiply functions //cout << add(5, 2) << endl; // 7 //cout << add(-4.2, 23) << endl; // 18.8 //cout << multiply(5, 3) << endl; // 15 //cout << multiply(7, 10) << endl; // 70 //Implement biggest and smallest functions. //cout << biggest(10, 2.2, 7) << endl; // 10 //cout << biggest(4.9, 5, 5) << endl; //5 //cout << biggest(8, 10, 20.3) << endl; //20.3 //cout << smallest(6, 20, 3) << endl; //3 //cout << smallest(3.14, 1.17, 8.3) << endl; //1.17 //Implement isEven, isOdd boolean functions // hint: think division //int n; //cout << "Enter a number: " << endl; //cin >> n; //if (isEven(n)) //{ // cout << n << " is even." << endl; //} //if (isOdd(n)) //{ // cout << n << " is odd." << endl; //} //Create a function that sums the numbers between the given range //int total1 = sum(8, 20); //this should be 8+9+10+...+20 = //int total2 = sum(9, 35); //cout << "The sum from 8 to 20 is " << total1 << endl; //cout << "The sum from 9 to 35 is " << total2 << endl; //Create a function that calculates power (x raised to the y) WITHOUT using the built-in pow function // (yes same as the hw, but lots of people just called pow which it tots cheats - if you didn't, you // already know the answer here) //cout << "4 raised to the 5 is " << power(4, 5) << endl; // 1024 //cout << "14 raised to the 3 is " << power(14, 3) << endl; // 2744 ////////////////////////////////////////////////////// // Okay, now something more interesting! // Prime numbers cannot be evenly divided by any number smaller than them except 1 // hint: computers don't mind doing lots of divisions //if (isPrime(n)) //{ // cout << n << " is prime." << endl; //} ////////////////////////////////////////////////////// // Write a function that lists all the prime numbers from 1 up to a certain number // hint: Functions may call other functions, even other functions that *you* have written. //listPrimes(10); //Should print: 2,3,5,7 //listPrimes(20); //Should print: 2,3,5,7,11,13,17,19 return 0; }