#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;
}
To write a program to check whether a particular number is a multiple of 5, or any other number for that matter, you check to see if the first number, modulus the second number, is zero.
if (N % 5 == 0) { /* N is divisible by 5 */ }
If you don't have the modulus (%) operator, you can use the explicit expression
if (N - int (N / 5) * 5 == 0) { /* N is divisible by 5 */ }
There is no modulus operator in C. Presumably you meant modulus in the literal sense to sum the absolute values of 5 signed integers. To obtain the absolute value of a signed integer, simply invoke the C standard library abs() function declared in <math.h>:
#include<math.h>
int sum_abs (int* arr, int size) {
int sum = 0;
for (int i=0; i<size; ++i) sum += abs (arr[i]);
return sum;
}
If you actually meant the modulo operator (%), it is not clear how you intend to use this operator to calculate a sum given that the modulo operator is a division operator (it returns the remainder after division) but it's not clear how the five values should be divided let alone what is to be summed.
The "%" operator gives the remainder of a division, for example: b = a % 5;
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.
write a c++ program to convert binary number to decimal number by using while statement
write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program
how to write a program that counts automorphic number from 1 to 999
You first learn how to program in C.
Write the first 6 Multiples of 12 and 14.
340, 680, 1020.
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 the first three common. multiples of 3,4,5
The first 3 multiples of 7 are: 7, 14, and 21.
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.
Even multiples of 5 must end with a zero.
Write a program to convert a 2-digit BCD number into hexadecimal
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.
Multiples of a Hundred thousand have a number followed by 5 zeroes Example: 300,000 400,000
There is no largest number. You can just keep going.
You can write 100 an infinite number of ways; as fractions, multiples, notations, and others.