help with arrays

need help to do a program that asks for 6 sixs numbers and saves them in a vector
then i need to do 3 subprograms
1 to calculate the biggest and the smallest number of all that where inserted
2 to calculate the double of the inserted numbers
3 to calculate the sum of the inicial inserted number and the respective double
someone help pls :)

 
  
What have you tried so far?
tried to do it with voids using for cicles
Show us what you've tried and we can help explain what can be changed/improved.
if i ask for someone to do it its because i ve tried and i cant do it myself so its easier for someone to try to do it and send me
For a starter - for 1) and 2) consider (assuming that 2 means sum of the double of the numbers):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

void bigsmall(const std::vector<int>& vi)
{
	const auto [small, big] {std::minmax_element(vi.begin(), vi.end())};

	std::cout << "The smallest number is " << *small << '\n';
	std::cout << "The biggest number is " << *big << '\n';
}

void doub(const std::vector<int>& vi)
{
	std::cout << "The double total is: " << std::accumulate(vi.begin(), vi.end(), 0) * 2 << '\n';
}

int main()
{
	const size_t nonums {6};
	std::vector<int> vi(nonums);

	std::cout << "Please enter " << nonums << " numbers: ";
	for (auto& v : vi)
		std::cin >> v;

	bigsmall(vi);
	doub(vi);
}



Please enter 6 numbers: 1 4 3 6 5 2
The smallest number is 1
The biggest number is 6
The double total is: 42

Last edited on
Topic archived. No new replies allowed.