top of page

Array inside a loop. Easy exercise.

  • a01337106
  • 10 feb 2015
  • 1 Min. de lectura

We now know how to store different data inside one single variable (an array).

First, remember the parts of the array. The size, index, indeces and the values inside an index. All of the indeces is the total length of an array. Each of those indeces is identified by one number from 0 to the length of the array minus une. Inside of each index a value is stored, this ones are elements inside the array.

Now we have to know how to apply them on exercises.

First let’s see an easy example:

This program will sum all of the values inside a established array A[] of size N

This are the values inside A[]:

[0] [1] [2] [3] [4] [5] [6]

2 6 9 12 6 4 8

with this, we already now that the size of the array is N=7

//The program

loop I from 0 to N-1

int sum=sum+A[I];

end loop

Each time the loop is executed the index of the searched part of the array will change. With this, every time a new index is selected, the value inside that index will be sum in the variable “sum”.

 
 
 

Comments


 THE ARTIFACT MANIFAST: 

 

This is a great space to write long text about your company and your services. You can use this space to go into a little more detail about your company. Talk about your team and what services you provide. Tell your visitors the story of how you came up with the idea for your business and what makes you different from your competitors. Make your company stand out and show your visitors who you are. Tip: Add your own image by double clicking the image and clicking Change Image.

 UPCOMING EVENTS: 

 

10/31/23:  Scandinavian Art Show

 

11/6/23:  Video Art Around The World

 

11/29/23:  Lecture: History of Art

 

12/1/23:  Installations 2023 Indie Film Festival

 FOLLOW THE ARTIFACT: 
  • Facebook B&W
  • Twitter B&W
  • Instagram B&W
 RECENT POSTS: 
 SEARCH BY TAGS: 

© 2023 by Karla Lugo. Proudly created with Wix.com

bottom of page