online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <type_traits> #include <cassert> //second parameter denotes the operator which can be +, - or * int calc(int numcount, char oper, int numarr[]) { //do check here that we don't go out of bounds assert(numcount > 0); int total = numarr[0]; // do the operatations for all the numbers in the array for (int i = 1; i < numcount; i++){ total = (oper == '-') * (total - numarr[i]) + (oper == '+') * (total + numarr[i]) + (oper == '*') * (total * numarr[i]); } return total; } int main() { int arr[] = {1,2,3,4,5,6}; std::cout << calc(6, '+', arr) << std::endl; //prints 21 std::cout << calc(6, '-', arr) << std::endl; //prints -19 std::cout << calc(6, '*', arr) << std::endl; //prints 720 }

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