Thanks for the reply..
I have a small doubt..Since we are using the same 'i' as the index to access the array elements,should n't reflect back on the left hand side when the decrement operation is done on the right hand side..i.e we are using 'i' as the index to access the array elemts and 'i' becomes 2 first on the right side and the same 'i' becomes 1 on the left hand side ,so effectively i now has 1 and arr[i] is now arr[1] and hence it...
User Profile
Collapse
-
arrays in JAVA
Hello Everyone..
The following code module is giving 13 as the answer in JAVA
class Number
{
public static void main(string args[])
{
int arr[] = {4,8,16};
int i = 1;
arr[++i] = --i;
System.out.prin tln(arr[0]+arr[1]+arr[2]);
}
I m getting the same output n c# as well...
But the same code in c and c++ is giving the output as 21.It is as below......
No activity results to display
Show More
Leave a comment: