Arrays- 1D, 2D and 3D

Concept of arrays

variable, index/subscript value and types of arrays (1D,2D,3D).

int []a=new int[5];

int i;

for(i=0;i<5;i++)

{ a[]=”enter number”; }

for(i=0;i<5;i++)

{sop(a[i]);}

DIFFERENCE BETWEEN STRUCTURE AND ARRAY

Structure- calls by value

Array-calls by reference

 

PROGRAMS

  1. sum of array elements
  2. square of subscript value
  3. find minimum and maximum value in a array

int []a=new int[5];

int i,s=0;

for(i=0;i<5;i++)

{

a[i]=….(“enter series”);

}

for(i=0;i<5;i++)

{

sopln(a[i]);

}

int b=a[0];

for(i=0;i<5;i++)

{

if(b>a[i])

b=a[i];

}

sop(“min”=+b);

int b=a[0];

for(i=0;i<5;i++)

{

if(b<a[i])

b=a[i];

}

sop(“max”=+b);

}

 

2D array

Class A

{

Public void static main(string []args)

{

Int [][]a=new int[3][4];

Int i,j;

For(i=0;i<3;i++)

{

For(j=0;j<4;j++)

{

A[i][j]=…(“enter number”);

}

}

For(i=0;i<3;i++)

{

For(j=0;j<4;j++)

{

Sop(A[i][j]);

}

}

}

Advertisements

Constructive and genuine appreciation and/or criticism most welcome

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s