online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
#include <iostream> #include <vector> int main() { int numberOfInputs = 0; std::cout<<"How many inputs?"<<std::endl; std::cin>>numberOfInputs;//take input into numberOfInputs std::vector<int> vectorOfInputs(numberOfInputs);//this vector(container) will contain all the inputs(both positive and negative) //this will contain the sum of all positive numbers int sum = 0; //this will count how many numbers entered by user are positive int countPositive = 0; //use for loop or any other loop populate the vector by user input for(int i = 0; i < numberOfInputs; ++i) { std::cout<<"input#"<<i+1<<":"; std::cin >> vectorOfInputs.at(i); //if the number is positive increase sum if(vectorOfInputs.at(i) >0) { sum += vectorOfInputs.at(i); ++countPositive; } } //print all the positive numbers for(int elem: vectorOfInputs) { if(elem>0) { std::cout<<elem<<std::endl; } } //print the sum and average std::cout<<"the sum of all the above positive numbers is: "<<sum<<std::endl; std::cout<<"the average of all the above positive numbers is: "<<(static_cast<double>(sum))/countPositive<<std::endl;//static_cast is used to get the result as double instead of int 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