Question

what do i do with line 57?
example:
length of array: 4
4 numbers for the array: 3 10 2 8
type the multiplier: 10
Type number of elements of the array to be multiplied: 2
values of the array: 15 50 2 8

and is my line 32 and 63 correct?
dont know how to multiply

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
using namespace std;

int askArraySize();
void askValues(int numbers[], int size);
int askMultiplier();
int askNumberOfElements();
void doMultiplication(int numbers[], int size, int multiplier, int n);
void dispValues(int numbers[], int size);

int main(){
	int size=0;
	int multiplier=0;
	int n=0;
	
	size = askArraySize();
	
	int numbers[size];
	askValues(numbers, size);
	
	multiplier=askMultiplier();
	
	n=askNumberOfElements();
	
	doMultiplication(numbers,size,multiplier,n);
	
	dispValues(numbers, size);
	
	return 0;
}

int askArraySize(){
	int size;
	cout << "Type the length of the array: ";
	cin >> size;
	return size;
}

void askValues(int numbers[], int size){
	cout << "Type " << size << " numbers for the array: ";
		for(int i=0;i<size;i++)
		cin >> numbers[i];
}

int askMultiplier(){
	int multiplier;
	cout << "Type a multiplier: ";
	cin >> multiplier;
}

int askNumberOfElements(){
	int n;
	cout << "Type number of elements of the array to be multiplied: ";
	cin >> n;
}

void doMultiplication(int numbers[], int size, int multiplier, int n){
		
		for(int i=0;i<n;i++)
		numbers[i] * multiplier;
}

void dispValues(int numbers[], int size){
	cout << "Values of the Array: ";
		cout << numbers << endl;
}


Last edited on
Topic archived. No new replies allowed.