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...
#include <stdio.h>
void main()
{
int arr[] = {4,8,16};
int i = 1;
arr[++i] = --i;
printf("%d",arr[0]+arr[1]+arr[2]);
}
How can the same program give different outputs in diffrent languages when the concept of array remains the same inall languages?
Can anyone tell me please?
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...
#include <stdio.h>
void main()
{
int arr[] = {4,8,16};
int i = 1;
arr[++i] = --i;
printf("%d",arr[0]+arr[1]+arr[2]);
}
How can the same program give different outputs in diffrent languages when the concept of array remains the same inall languages?
Can anyone tell me please?
Comment