online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <iostream> #include <iomanip> #include <string> using namespace std; const int COLUMNS = 3; /**Computes the total of a row in a table. @param table a table with 3 columns @param row the row that needs to be totaled @return the sum of all elements in the given row*/ double row_total(int table[][COLUMNS], int row) { int total = 0; for (int j = 0; j < COLUMNS; j++) { total = total + table[row][j]; } return total; } int main() { const int COUNTRIES = 8; const int MEDALS = 3; string countries[] = {"Canada","Italy","Germany","Japan", "Kazakhstan", "Russia", "South Korea", "United States"}; int counts[COUNTRIES][MEDALS] = { { 0, 3, 0 }, { 0, 0, 1 }, { 0, 0, 1 }, { 1, 0, 0 }, { 0, 0, 1 }, { 3, 1, 1 }, { 0, 1, 0 }, { 1, 0, 1 } }; cout << " Country Gold Silver Bronze Total" << endl; // Print countries, counts, and row totals for (int i = 0; i < COUNTRIES; i++) { cout << setw(15) << countries[i]; // Process the ith row for (int j = 0; j < MEDALS; j++) { cout << setw(8) << counts[i][j]; } int total = row_total(counts, i); cout << setw(8) << total << endl; } 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