how to add elements in an array in for loop c 2b 2b

Solutions on MaxInterview for how to add elements in an array in for loop c 2b 2b by the best coders in the world

showing results for - "how to add elements in an array in for loop c 2b 2b"
Kat
04 Sep 2016
1
2
3int * myVar = new int [5];
4for (int i = 0; i < 5; i++)
5	myVar[i] = i
6
7// 0 1 2 3 4 myVar in the array 
8
9// delete stuff *optional*
10delete [] myVar;
11myVar = NULL; 
12
13// free up memory declared on the stack
14