1#include <iostream>
2#include <cstdarg>
3using namespace std;
4
5double average(int num,...) {
6 va_list valist; // A place to store the list of arguments (valist)
7 double sum = 0.0;
8 int i;
9
10 va_start(valist, num); // Initialize valist for num number of arguments
11 for (i = 0; i < num; i++) { // Access all the arguments assigned to valist
12 sum += va_arg(valist, int);
13 }
14 va_end(valist); // Clean memory reserved for valist
15
16 return sum/num;
17}
18
19int main() {
20 cout << "[Average 3 numbers: 44,55,66] -> " << average(3, 44,55,66) << endl;
21 cout << "[Average 2 numbers: 10,11] -> " << average(2, 10,11) << endl;
22 cout << "[Average 1 number: 18] -> " << average(1, 18) << endl;
23}
24
25/*
26NOTE: You will need to use the following 'data_types' within the function
27va_list : A place to store the list of arguments (valist)
28va_start : Initialize valist for num number of arguments
29va_arg : Access all the arguments assigned to valist
30va_end : Clean memory reserved for valist
31*/
1#include <iostream>
2
3// Define name_x_times() below:
4void name_x_times(std::string name, int x){
5while(0 < x){
6 std::cout << name << ""
7}
8}
9
10int main() {
11
12 std::string my_name = "Add your name here!";
13 int some_number = 5; // Change this if you like!
14 // Call name_x_times() below with my_name and some_number
15
16
17} // this put shit inside of the shit, look back at your adventure.cpp code future me.