About arrays and For loops in any language:
Syntax:
if(condition) for(initilization;condition;inc/dec)
{ {
//statements
//statements }
}
else
{
//statements
}
example for storing example for storing
a[0]=0 a[0]=5
a[1]=1 a[1]=4
a[2]=2 a[2]=3
a[3]=3 a[3]=2
a[4]=4 a[4]=1
a[5]=5 a[5]=0
------------------------------------- -----------------------------------------------
int a[6]; int a[6];
for(int i=0;i<6;i++) for(int i=0,j=5;i<6 && j>=0;i++,j--)
{ {
a[i]=i; a[i]=j;
} }
------------------------------------- --------------------------------------------------
------------------------------------- -----------------------------------------------
int a[6]; int a[6];
for(int i=0;i<6;i++) for(int i=0,j=5;i<6 && j>=0;i++,j--)
{ {
a[i]=i; a[i]=j;
} }
------------------------------------- --------------------------------------------------






0 comments:
Post a Comment