Question

2. Determine the following information about each value in a list of positive integers. Is the value a multiple of 7, 11, or 13? a. b. Is the sum of the digits odd or even? (parameter output returns 0 for even, 1 for odd) Is the value a prime number? (parameter output returns 0 nonprime, 1 for prime) c. You should write three functions: 1)input, 2) processing, 3)output 1) Input wil have one output parameter of type int stating the number of input items to process. Processing should have one input parameter stating the number of items to process, three 2) 3) output parameters to answer the above three questions Output will have 3 input parameters to display the results.

C+ using pointers

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream> using namespace std; int is_multiple (int num) / checking multiple of if (num% 7.0 ) return7 else if(num%int is_prime (int num) // checking if number is prime // if prime return 1 or if non prime return if (num(#1) return 0; int fvoid output (int num, int mul, int sum, int prime) / displaying the result coutくくnum<< is :くくendl ; cout<<Not a multiple o/ driving progran int main int main () int ary[]={10, 11,7,13,15); int num, mul, sum,prime: input (&num) for ( int i=0; ǐくnunEnter number of items to process :5 10 is: Not a multiple of 7,11,or 13. Sum of the digits is odd Value is a non prime number

Add a comment
Know the answer?
Add Answer to:
C+ using pointers 2. Determine the following information about each value in a list of positive...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • (Please use C language, not C++) Determine the following information about each value in a list...

    (Please use C language, not C++) Determine the following information about each value in a list of positive integers. a. Is the value a multiple of 7, 11, or 13? b. Is the sum of the digits odd or even? (parameter output returns 0 for even, 1 for odd) c. Is the value a prime number? (parameter output returns 0 nonprime, 1 for prime) Use an output file for results. The goal is to implement both pass by value and...

  • 3. [30pts] Determine the following information about a value passed in as a parameter. (a) Is...

    3. [30pts] Determine the following information about a value passed in as a parameter. (a) Is the value a multiple of 7, 11 or 13? (b) The sign of the value (-1 if it is negative, 0 if it is 0 and 1 if the value is positive). You should write a function with three type int parameters, one input parameter (the value) and two other output parameters. The function should send back the answers to the two questions above...

  • PROGRAMMING IN C. 1) The first program will compute compounded interest. Suppose you invest $1000.00 at...

    PROGRAMMING IN C. 1) The first program will compute compounded interest. Suppose you invest $1000.00 at an interest rate of 2% per year. If the interest is computed at the end of each day, it is added to your account (i.e., the interest is compounded daily). Print what the account value will be at the end of each year for 20 years. Use data type double for money. For 365 days per year (ignore leap year), the daily interest rate...

  • Is Prime Number In this program, you will be using C++ programming constructs, such as functions....

    Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...

  • 20. [5 points] Rewrite the following ML. function using patterns fun factn. ifn-0 then 1 else n fact (n-1) 21. [S points) Using map function, write an ML function int2real of type int list real l...

    20. [5 points] Rewrite the following ML. function using patterns fun factn. ifn-0 then 1 else n fact (n-1) 21. [S points) Using map function, write an ML function int2real of type int list real list that takes a list of integers and returns the same numbers converted to real. For example, if the input is [1,2,3], the output should be like [1.0,2.0,3.0 22. [5 points] Using foldr function, write a function duplist of type·a list 'a list that takes...

  • How to solve it using Python? 5. Write a function called no_squares which takes an input...

    How to solve it using Python? 5. Write a function called no_squares which takes an input parameter N, a positive integer, and returns: 1 if N is not divisible by a square and has an even number of prime factors -1 if N is not divisible by a square and has an odd number of prime factors 0 if N is divisible by a square For example, no-squares (10) returns 1 (since 10 = 2x5), no-squares (30) returns-1 (since 30...

  • Please use Python Exercise 1 Create a program named sentinel_loop using break. This program should implement...

    Please use Python Exercise 1 Create a program named sentinel_loop using break. This program should implement functionality that is the same as the Part 1 tutorial example, except for the following differences: • • This program should count even and odd integers. This program should report counts of even and odd integers. Remember that even integers can be identified using the test condition: value % 2 == 0 Remember to test your code for appropriate behavior when the user signals...

  • Please Use C++ for coding . . Note: The order that these functions are listed, do...

    Please Use C++ for coding . . Note: The order that these functions are listed, do not reflect the order that they should be called. Your program must be fully functional. Submit all.cpp, input and output files for grading. Write a complete program that uses the functions listed below. Except for the printodd function, main should print the results after each function call to a file. Be sure to declare all necessary variables to properly call each function. Pay attention...

  • •The multiplication operator works by summing some value, x, by another value, y. Write a function...

    •The multiplication operator works by summing some value, x, by another value, y. Write a function definition called multiply that takes two integer parameters to perform the operation described. Return the answer to the calling function. •Write a function called randCount with no parameters. The function should randomly generate 5 numbers between 8 to 15 and counts how many times a multiple of 2 occurred. Return the answer to the calling function. •Write a function called summary that takes as...

  • JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a...

    JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT