Question

This code is in C++ Write a function named printMultTable that takes 2 integers, numValues and...

This code is in C++

Write a function named printMultTable that takes 2 integers, numValues and factor, and prints the first numValues greater than 0 that are multiples of  factor, separated by SPACE. It has no return value.

printMultTable(5, 4) should print the first 5 multiples of 4, separated by a space, which is "4 8 12 16 20"
printMultTable(3, 6) should print the first 3 multiples of 6, separated by a space, which is "6 12 18"   

Homework Answers

Answer #1
#include <iostream>

using namespace std; 

void printMultTable(int n, int m){
   for(int i = 1;i<=n;i++){
      cout<<(m*i)<<" ";
   }
}

int main() {
   printMultTable(5,4);
   return 0;
}

void printMultTable(int n, int m){
   for(int i = 1;i<=n;i++){
      cout<<(m*i)<<" ";
   }
}
Know the answer?
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
Similar Questions
Explain your code with comments. Solve in C++. Write a function named myFunc3() that takes a...
Explain your code with comments. Solve in C++. Write a function named myFunc3() that takes a 2D integer array NUMBERS[][50], and it size n and m. Then the function will print the sum of each row in one line.
JAVA Problem 1: Summing It Up Write a program, which takes two distinct integers separated by...
JAVA Problem 1: Summing It Up Write a program, which takes two distinct integers separated by space as input and prints the sum of all the integers between them, including the two given numbers. Note that the numbers can appear in either order. You may assume that both numbers are between –10, 000 and 10, 000. For example, if the input is as follows: 10 4 the output should be 49, since 10+9+8+7+6+5+4=49. Similarly, if the input is -3 10...
USE C++ Write a function named find that takes a pointer to the beginning and a...
USE C++ Write a function named find that takes a pointer to the beginning and a pointer to the end (1 element past the last) of an array, as well as a value. The function should search for the given value and return a pointer to the first element with that value, or the end pointer if no element was found.
In Coral,write a program that reads a list of 10 integers and outputs those Integers in...
In Coral,write a program that reads a list of 10 integers and outputs those Integers in Reverse. For coding Simplicity, follow each output integer by a space, including the last one. Then, output a new line. Example if the input is 2 4 6 8 10 12 14 16 18 20, the output is: 20 18 16 14 12 10 8 6 4 2 to achieve above first read the integers into an array. Then output the array in reverse
Write a function count_div5(nested_list) that takes in a list of lists of integers, and returns a...
Write a function count_div5(nested_list) that takes in a list of lists of integers, and returns a list of integers representing how many integers in each sublist of the original were divisible by 5. Examples: >>> count_div5([[5, 3, 25, 4], [46, 7], [5, 10, 15]]) [2, 0, 3] >>> count_div5([]) [] >>> count_div5([[-20, 10, 2, 4, 5], [], [5], [8, 25, 10], [6]]) [3, 0, 1, 2, 0]
Write a function in (C++) named - accending_order - that takes a reference to a vector...
Write a function in (C++) named - accending_order - that takes a reference to a vector of string (like {"HI 32", "HELLO 78", "NAME 97", "WORLD 07"}), and returns nothing. The function should reorder the vector so that the courses are sorted by number in ascending order. Write this function without - int (main). CODE IN C++ ONLY. EXPECTED OUTPUT: {"WORLD 07", "HI 32", "HELLO 78", "NAME 97"}
In C programming language write a function that takes an integer n as input and prints...
In C programming language write a function that takes an integer n as input and prints the following pattern on the screen: 1 (n times) 2 (n-1 times) .n (1 time) For example, if n was 5, the function should print 1 1 1 1 1 2 2 2 2 3 3 3 4 4 5
(C++) Write a function called triple that takes an array of integers as a parameter as...
(C++) Write a function called triple that takes an array of integers as a parameter as well as the length of the array. It should triple each value in the array. The function should not return anything. (Note that the contents of the array WILL be modified.)
Write a function in C++ that takes an integer argument D and returns the index and...
Write a function in C++ that takes an integer argument D and returns the index and value of the first D-digit Lucas number. Turn in a print-out of your code, as well as the index and value your function returns when D = 15. Example) Let D = 3. The first 3-digit Lucas Number is L10 = 123, so your function should return something like firstDDigitLucas(3) = (10, 123).
Write Java code that attempts to call a method named bootUp() which takes a String parameter...
Write Java code that attempts to call a method named bootUp() which takes a String parameter and returns an integer value. The String parameter should be read from a file named "bootConfig.txt" and is the only value in the file. If a BootUpException is thrown, print the Exception object's message. If a DriverException occurs, call the reboot() method and rethrow the original DriverException object. If any other type of Exception is thrown, print a generic error message to the console....