answersLogoWhite

0

Loops can be used to iterate or walk through an array. For example, suppose you have an array already initialized (we'll call it "array"):

int target = -1;

for (i=0; i < array.length(); i++){

if (array[i] = target){

//do something

}

}

Here, we will walk through an array (note that arrays are zero indexed) using a loop to make sure we hit each element of the array. In our loop, we start at the head (or first element) and iterate over each element.

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

How can loops be used to process arrays give examples?

How_can_loops_be_used_to_process_arrays


Can arrays be used in for loops?

yes


What are the basic parts of the c language?

That would include header files, data types, loops, functions, pointers, arrays


Can you use the loops and arrays together?

Yes. int main(void){ int a[10]; int i=0; while(i&lt;10 &amp;&amp; a[i++]=i); return 0; }


What is difference between Bac arrays and DNA arrays?

BAC (Bacterial Artificial Chromosome) arrays are a type of DNA arrays. BAC arrays are usually used for a technique called array CGH (Comparative Genomic Hybridisation) which is used to identify gross deletions or amplifications in DNA (which for example is common in cancer). DNA arrays include BAC arrays but also oligo, cDNA, and promoter arrays. Oligo and cDNA arrays are typically used for gene expression analysis (looking to see how heavily expressed each gene is). Oligo arrays can also be used for SNP (single nucleotide polymorphism) analysis. Promoter arrays are used to identify transcription factor binding sites.


How can arrays be used for inter function communication?

The size of a function can be determined from the size of the array. Arrays and functions are both used in computer programming.


How can the word loops be used in a sentence?

Her garden appeared to be edged with loops of wrought iron.


Why are matrices used for representation while programming?

Let me correct you: two-dimensional arrays are used in programming to represent matrices. (Matrices are objects of mathematics, arrays are objects of programming.)


What are the loops on the floor of a transit van called?

The loops on the floor of a transit van are called loop anchors. The loops are used to safely secure wheelchairs in the van.&Ecirc;


Why you use Loops?

Loops are used to repeat the execution of the same set of instructions again and again in a program.


What are loops in C?

In very simple terms, Loops in any language are used to perform a task repetitively.


Dynamically allocated array waste storage and time?

It's actually not true. In order to make a good program which can work with big arrays you have to use dynamic arrays because you can cleam memory used by dymanic arrays any time. For static arrays is not true, memery which was reserved for static arrays will be available for other applications only when you finish working with your application (which is working with static arrays).