answersLogoWhite

0

#include<iostream>

#include<vector>

std::vector<size_t> multiples(size_t const num, const size_t terms)

{

std::vector<size_t> result;

size_t term=0;

while (++term<=terms)

result.push_back (num*term);

return result;

}

int main()

{

const std::vector<size_t> mults = multiples (42, 5);

std::cout << "The first 5 multiples of 42 are:";

for (auto value : mults) std::cout << '\t' << value;

std::cout << std::endl;

}

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

manthan?

Write the first 6 Multiples of 12 and 14.


Write a java program using forloop to generate the first 10 multiples of the first 10 natural numbers?

Here's a simple Java program that uses a for loop to generate the first 10 multiples of the first 10 natural numbers: public class Multiples { public static void main(String[] args) { for (int i = 1; i &lt;= 10; i++) { System.out.print(&quot;Multiples of &quot; + i + &quot;: &quot;); for (int j = 1; j &lt;= 10; j++) { System.out.print(i * j + &quot; &quot;); } System.out.println(); } } } This program iterates through the first 10 natural numbers and prints their multiples from 1 to 10.


How do you write a program to print the first n multiples of 7?

Algorithm: multiples input: two positive integers, m and n output: print first n multiples of m i = m; for j = 1 to n print i i = i + m; next j


Write down the first 3 multiples of 7?

The first 3 multiples of 7 are: 7, 14, and 21.


Identify the first three common multiples of 4 and 5?

write the first three common. multiples of 3,4,5


How can number patterns help in finding the least common multiples?

Example: Find the LCM of 12 and 30.Write the multiples of 12: 12, 24, 36, 48, 60, 72, ...Write the multiples of 30: 30, 60, 90, ...The first number you find which is in both lists is the LCM: 60.


Multiples of 5 in even number write in rule form?

Even multiples of 5 must end with a zero.


Write a program to convert a 2 digit BCD number into hexadecimal number?

Write a program to convert a 2-digit BCD number into hexadecimal


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


How do write out multiples of a hundred thousand?

Multiples of a Hundred thousand have a number followed by 5 zeroes Example: 300,000 400,000


What is the largest number you can write using the multiples of 3?

There is no largest number. You can just keep going.


What is the lowest common multiple of 8 and 10 how is it 40?

Least common multiple of 8 and 10 is 40 that's like this write down multiples of the whole number 8 first, they are 8,16,24,32,40,48,56,64,72,80,88 etc.. now write down multiples of the whole number 10,they are 10,20,30,40,50,60,70,80,90 etc...... as you can see 40 and 80 are common multiples in the series but 40 is the smallest one hence it is the LCM of 8 and 10