Question

In: Computer Science

Write a function, named isMultipleOfFive that accepts integer argument. When the function is called, it should...

Write a function, named isMultipleOfFive that accepts integer argument. When the function is called, it should display if the argument "is a multiple of 5" or "is not a multiple of 5".

Solutions

Expert Solution

Source Code:

Output:

Code in text format (See above images of code for indentation):

#include <iostream>
using namespace std;
/*main function*/
int main()
{
   /*function prototype*/
   void isMultipleOfFive(int);
   int n;
   /*read a integer from user*/
   cout<<"Enter a number: ";
   cin>>n;
   /*function call*/
   isMultipleOfFive(n);
   return 0;
}
/*function definition*/
void isMultipleOfFive(int n)
{
   /*check if multiple of 5 or not*/
   if(n%5==0)
       cout<<n<<" is a multiple of 5";
   else
       cout<<n<<" is not a multiple of 5";
}


Related Solutions

Python: Write a function named calc_odd_sum that accepts a positive integer as the argument and returns...
Python: Write a function named calc_odd_sum that accepts a positive integer as the argument and returns the sum of all the odd numbers that are less than or equal to the input number. The function should return 0 if the number is not positive. For example, if 15 is passed as argument to the function, the function should return the result of 1+3+5+7+9+11+13+15. If -10 is passes, it shall return 0. You shall run the program test the result at...
Write a function called HW5_P1 that accepts 1 input argument: an array, a. The function should...
Write a function called HW5_P1 that accepts 1 input argument: an array, a. The function should output an array, b, that is computed as: b=3a+5. Write a MATLAB function called “fit_line” that accepts 2 input arguments: a column vector of x data and a column vector of y data. The nth element in the input arguments should correspond to the nth Cartesian data point i.e. (xn,yn). The function should compute and return 2 outputs: the slope, m, and the y...
Write a function in JAVASCRIPT that accepts an array as argument. The function should loop through...
Write a function in JAVASCRIPT that accepts an array as argument. The function should loop through the array elements and accumulate the sum of ASCII value of each character in element and return the total. For example: function([‘A’, ‘bc’, 12]); // returns 361 which is the sum of 65 + 98 + 99 + 49 + 50 Use of any built in string functions or built in array functions is not allowed, Any help would be much appreciated
Make a python code. Write a function named max that accepts two integer values as arguments...
Make a python code. Write a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two. Write the program as a loop that...
/** * Write a recursive function that accepts a Queue<Integer>. It * should change every int...
/** * Write a recursive function that accepts a Queue<Integer>. It * should change every int in this queue to be double its original * value. You may NOT use loops or any other data structures besides * the queue passed in as a parameter. You may use a helper function. * @param q */ public static void doubleElements(Queue<Integer> q) {}
#Write a function called "load_file" that accepts one #parameter: a filename. The function should open the...
#Write a function called "load_file" that accepts one #parameter: a filename. The function should open the #file and return the contents.# # # - If the contents of the file can be interpreted as # an integer, return the contents as an integer. # - Otherwise, if the contents of the file can be # interpreted as a float, return the contents as a # float. # - Otherwise, return the contents of the file as a # string. #...
Given the following C function prototype which accepts an integer argument, complete the implementation of the...
Given the following C function prototype which accepts an integer argument, complete the implementation of the function in C language to return the number of 1’s in the binary representation of the number passed. For example if the number is (011100011 ) then the function should return 5 as the number of 1s. Please remember that an integer is 32 bits long. USE the following function int countOnes(int number) Write a full c program that has the header required and...
In java Write a static method named consecutiveDigits that accepts an integer n as a parameter...
In java Write a static method named consecutiveDigits that accepts an integer n as a parameter and that returns the highest number of consecutive digits in a row from n that have the same value. For example, the number 3777785 has four consecutive occurrences of the number 7 in a row, so the call consecutiveDigits(3777785) should return 4. For many numbers the answer will be 1 because they don't have any adjacent digits that match. Below are sample calls on...
Write a complete static method named addUp that accepts, in order, an integer number and an...
Write a complete static method named addUp that accepts, in order, an integer number and an integer thisMany as parameters and that prints a complete line of output reporting all the numbers that result from adding number to itself thisMany number of times (starting at 1 and ending at thisMany). For example, the following calls: addUp(3, 5); addUp(7, 3); should produce this output: Adding up 3 for 5 times gives: 3, 6, 9, 12, 15 Adding up 7 for 3...
In Java, write a recursive function that accepts a string as its argument and prints the...
In Java, write a recursive function that accepts a string as its argument and prints the string in reverse order. Demonstrate the function in a driver program.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT