Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: xample, the assignment statement marks[4]=83; Stores the element 83 at fifth location It will look like in memory as: 0 1 marks 2 3 45 83 83 Displaying the stored elements/output from array 6 To display the stored data element we use the output statement as: cout<<marks[4]; It will display the value stored at fifth locations i.e. 83 7 8 9 To initialize one dimensional array at design time as under To initialize one dimensional array at design time as under main() { int marks[5]={230, 400, 500, 453 , 590 }; ­­­­­­­­­­­­ ­­­­­­­­­­­­ ­­­­­­­­­­­­ } It look like this in memory 0 marks 1 2 3 4 230 400 500 453 590 Input/output at runtime in Array Input/output at runtime in Array void main() main() { iint marks[10],i; nt /*reserve 10 memory locations*/ /*reserve for(i=0; i<10; i++) for(i=0; cin>>marks[i]; /*Storing values in an array*/ /*Displaying the elements of array*/ for(i=0 ;i<10; i++) for(i=0 cout<<marks[i]; } Two Dimensional Array Two In two dimensional arrays the data elements are stored in a sequence of memory locations but the data values to be stored are in form of table or matrix (Rows a...
View Full Document

This document was uploaded on 03/16/2014.

Ask a homework question - tutors are online