Data Structures | Array | Question 2

Last Updated :
Discuss
Comments

What will the output of the below code?

C++
#include <iostream>
using namespace std;

int main()
{

    int arr[2] = { 1, 2 };
    cout << arr[0] << ", " << arr[1] << endl;
    return 0;
}
Java
public class Main {
    public static void main(String[] args) {
        int[] arr = {1, 2};
        System.out.println(arr[0] + ", " + arr[1]);
    }
}

1, 2

Syntax error

Run time error

None

Share your thoughts in the comments