In: Computer Science
2. Write a program C++ that asks the user for a number (not necessary to force any particular requirements). Write a function with the following signature: double square(double x) that returns the square of the user's number (x * x).
3. Write a C++ program that asks the user for an integer. Write a function that returns 1 of the number is even, and 0 if the number is odd. Use this function signature: int isEven(int x).
4. Write a program C++ that asks the user for two integers. Write a function that takes those two numbers as input and returns the largest of the two numbers.
5. Write a function that tests whether the integer is prime. If the number is prime, return 1, else return 0. Use this function in a program that does the following: (1) Asks the user for a positive integer; (2) outputs all of the prime numbers between 1 and that number.
2) The main function contains the input value entering procedure and the function double square(double x) calculates the value.
CODE WITH EXPLANATION-
OUTPUT-
3) Same procedure as in previous question, and explanation provided in code itself.
OUTPUT-
4) The function isGreater(x,y) compares and returns the greater value between x and y.
OUTPUT-
5) 1) PrimeCheck FUNCTION-
Main function-
OUTPUT-
5) 2)
PrimeCheck function is exactly same as in previous part. Only main function is changed-
OUTPUT-