168k views
5 votes
Given a one-dimensional array named yearlySalesTotals that contains decimal values, code the first line of a foreach statement that will let you access each element in the array in a variable named yearlySalesTota

1 Answer

5 votes

Answer:

Following are the code

int k;// variable declaration

for ( k = 0; k < yearlySalesTotals.Length; k++) // iterating the loop

{

cout<<yearlySalesTotals[k]; // accesing the each element

}

Step-by-step explanation:

Following are the description of code

  • In this, we declared a variable "k" of "int" type.
  • initialized the value of "k" to 0 in the for a loop.
  • Set the condition in the loop for controlling and accessing the element of the array i.e yearlySalesTotals.Length;
  • Inside the loop, we print the value of array in one by one.
  • Increment the value of "k" by 1.
User Tugcem
by
5.8k points