a[k] here k is the memory location
a[i]=a[i+1]
means the data in a[i+1] is stored in a[i]
this type of statements might be used for sorting codes
where we need to interchange nos
to interchange nos within a array
temp=a[i]
a[i]=a[i+1]
a[i+1]=temp
What is the function of these codings" a[i]=a[i+1] %26amp; a[i+1]=a[1] " in C programming language?
its an array a[] every time array a[]'s location would increment in the first and in the second array a[]'s location would a[1]. This mean on different locations of a[] there would be different value. lets say the array is meant to store numeric value. array's start from 0 so at location a[0] something of numeric value is stored. and at location a[1] something else is stored. Array is easy to use instead of using lot of variables you can use an array and eliminate the use of multiple variables.
Reply:In c/c++, we use arrays for variables.
like a[1],a[2],a[3], etc.
eg: In a program, lets say variable a[1] holds the value 20 and a[2] holds 40. we can access the variable either by a[1] and a[2] or store a value 1 in new variable i and use it as a[i]. so a[i] will mean same as a[1].
So, considering that i=1, code a[i]=a[i+1] means a[1]=a[1+1] ie a[1]=a[2]. This means that the value of a[1] will be replaced by a value of a[2].
result of our eg: a[1] will now contain 40.
Left hand side (of the equals to sign "=") gets assigned the value from the Right hand side.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment