Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Through keyboard input, calculate the sum of all elements of any integer one-dimensional array and output it.
Through keyboard input, calculate the sum of all elements of any integer one-dimensional array and output it.
# Contains? & ltiostream & gt

Use? Namespace? std

int? Master ()

{

int? n; //Number of array elements stored

cout? & lt& lt? Please enter the number of array elements? & lt& lt? endl

cin? & gt& gt? n;

int? *iArray? =? New? int[n];

cout? & lt& lt? "Come in"? & lt& lt? n? & lt& lt? "Integer:" & lt& lt? endl

For what? (int? I = 0; ? Me? & lt? n; ? I++)// Enter the values of n arrays.

{

cin? & gt& gt? IAR ray[I];

}

int? sum? =? 0; //Save the sum of array elements.

For what? (int? j = 0; ? j? & lt? n; ? j++)? //Find the sum of array elements

{

sum? +=? IAR ray[j];

}

cout? & lt& lt? What is the sum of arrays? & lt& lt? sum? & lt& lt? endl

Return? 0;

}

Screenshot of running case: