array without pointer & vector

finally i can use the alternative way of array :)

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
#include<iostream>

using namespace std;

int main()
{
	int sizeArray, j, k, multiplication[j], addition[j], array1[j], array2[j]; 
	
	cout<<"Welcome! This Program Will Multilpy and Add Two Numbers" << endl << endl;
	cout<<"Please Enter the Size of Array : ";

	cin>> sizeArray;
	cout<< endl;

	cout<<"Please enter the value for the first array: "<<endl;

	for(int j=0,k=0; j< sizeArray; j++, k++)
		{
      	cout<< k + 1 << ": ";
			cin>> array1[j];
		}

	cout<<"\n\nPlease enter the value for the second array: "<<endl;
	for(int j=0, k=0; j< sizeArray; j++, k++)
		{
      	cout<< k + 1 << ": ";			
			cin>> array2[j];
		}


	cout << "\n\nMultiplication :"<<endl;
	for(int j=0; j< sizeArray; j++)
		{
			multiplication[j]= array1[j] * array2[j]; 
			cout<< multiplication[j]<< endl;
		} 
	
	cout << "\n\nAddition :"<<endl;
	for(int j=0; j< sizeArray; j++)
		{
			addition[j] = array1[j] + array2[j];
			cout<< addition[j]<< endl;
		} 

	cout<<endl;
system("PAUSE");
return 0;
}
I have not looked through the whole program but it is enough to point out that this statement

int sizeArray, j, k, multiplication[j], addition[j], array1[j], array2[j];

is already invalid.
+1, Vlad. Also I think I've seen this code somewhere else on this forum, haven't I? There must be some bad teacher somewhere in the world.
@EssGeEich
There must be some bad teacher somewhere in the world.


I think that this teacher is some C++ compiler that allows to use VLA (defined in C) in C++ code.:)
Topic archived. No new replies allowed.