online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { srand(time(0)); const int m = 3; const int n = 3; int matrix[m][n]; // 2D matrix declaration // Fill random values in the matrix for ( int i = 0; i < m; i++ ) { for ( int j = 0; j < n; j++ ) { matrix[i][j] = rand() % 100; } } // Print the matrix for ( int i = 0; i < m; i++ ) { for ( int j = 0; j < n; j++ ) { cout << matrix[i][j] << " "; } cout << endl; } cout << endl; // Swap the columns for ( int i = 0; i < m; i++ ) { for ( int j = 0; j < n/2; j++ ) { int tmp = matrix[i][j]; matrix[i][j] = matrix[i][n-1-j]; matrix[i][n-1-j] = tmp; } } // Transpose the matrix for ( int i = 0; i < m; i++ ) { for ( int j = i + 1; j < n; j++ ) { int tmp = matrix[i][j]; matrix[i][j] = matrix[j][i]; matrix[j][i] = tmp; } } // Print the rotated matrix for ( int i = 0; i < m; i++ ) { for ( int j = 0; j < n; j++ ) { cout << matrix[i][j] << " "; } cout << endl; } }

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