Question

- Write a function that takes two integer inputs and returns the sum of all even numbers between these inputs, and another function that takes two integer inputs and returns the sum of odd numbers between these inputs .In main function, the program will asks the user to enter two integer numbers and then passes them to these two functions and display the result of each of them. [0.5 mark] (BY USING C PROGRAM)

Answer #1

Function Example: Write a Python function that receives two integer
arguments and writes out their sum and their product. Assume no
global variables.
def writer(n1, n2):
sum = n1 + n2
product = n1*n2
print("For the numbers", n1, "and", n2)
print("the sum is", sum)
print("and the product is", product)
...
1) Create a PYHW2 document that will contain your algorithms in
flowchart and pseudocode form along with your screen shots of the
running program.
2) Create the algorithm in both...

For C++:
a) Write a function is_prime that takes a positive integer X and
returns 1 if X is a prime number, or 1 if X is not a prime
number.
b) write a program that takes a positive integer N and prints
all prime numbers from 2 to N by calling your function is_prime
from part a.

In C++
1) Write the function definition that has 1 pass by value
integer parameter. The function contains logic to return true if
the parameter is even and false if it is not.
2 ) Write a main function that prompts the user for a value,
calls the function that you created in step one with the value
entered by the user, display "even" if the function return true and
otherwise displays "odd"

Write a program containing a function,
reverseDigit, that takes an integer as a parameter
and returns the number with its digits reversed, then printout the
return result. For example, the value of
reverseDigit(12345) is 54321; the value of
reverseDigit(5600) is 65; the value of
reverseDigit(7008) is 8007; and the value of
reverseDigit(-532) is -235.
Modify the following program to make a correct output.
/*
// Name: Your Name
// ID: Your ID
// Purpose Statement: ~~~
*/
#include <iostream>...

Write 2 C functions.
One returns the maximum of 5 numbers. The other function,
returns the minimum of 5 numbers.
In your main function, prompt the user to input 5 numbers and
call the 2 functions above.

Define a function math(num1, num2, operation) that takes three
arguments and it should perform math operations ( +,-,* and /) on
two numbers num1 and num2 based on the operation symbol, and then
it should return the result. The main part of the program should
prompt users to provide num1, num2, and an operation symbol
separately and then call the function with user inputs and display
the result back to the user.
Function definition should look like this in your...

Write a mips assembly language program that asks the
user to enter and integer number and read it. Then ask him to enter
a bit position (between 0 and 31) and display the value of that
bit.

IN PYTHON : Write a program that asks the user for a number.
Write the number to a file called total.txt. Then ask the user for
a second number. Write the new number on line 2 with the total for
both numbers next to it separated by a comma. Then ask the user for
a third number and do the same. Keep asking for numbers until the
person puts in a zero to terminate the program. Close the file. Be...

Here are the function prototypes
for your homeworkWrite out the actual functions themselves Also, create a main function that demonstrates that all four
functions work The user should be able to provide four values to
your program (three floats and an int) Your program should then
use your four new functions and also display the results to the
user NONE of these functions should print values themselvesfloat sum( float x, float y, float z ); // returns the sum of
three floatsfloat mean( float...

Write in C++ a function int sumofdigits( int n ) which computes
and returns the sum of the digits of
n.
Use the following main function to test your code:
int main()
{
int n, sn;
cout << "Enter q to quit or an integer: ";
while ( cin >> n )
{
sn = sumofdigits(n);
cout << "sumofdigits( " << n << " ) = " <<
sn;
cout << "\nEnter q to quit or an integer: ";
}...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 3 minutes ago

asked 9 minutes ago

asked 12 minutes ago

asked 15 minutes ago

asked 15 minutes ago

asked 15 minutes ago

asked 24 minutes ago

asked 32 minutes ago

asked 37 minutes ago

asked 46 minutes ago

asked 49 minutes ago

asked 54 minutes ago