online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <bits/stdc++.h> using namespace std; class matrix { int size; int *a; public: matrix(int size) //Matrix class { this->size = size; a = new int[(size * (size - 1) / 2)]; //creating 1-D array to store values } void set(int i, int j, int val) //Function to set values in array "a". { if (i >= j) a[((i * (i - 1)) / 2) + (j - 1)] = val; } void display() //function to display values { for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { if (i >= j) cout << a[((i * (i - 1)) / 2) + (j - 1)] << " "; else cout << "0 "; } cout << endl; } } }; int main() { int n = 3; //dimension of matrix matrix a(n); for (int i = 0; i < n; i++) //entering the values { int val; for (int j = 0; j < n; j++) { cin >> val; a.set(i, j, val); } } a.display(); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue