I am experimenting with an online compiler, but I keep getting errors when I try to run the below program, stating that the variables were not declared in scope. I am declaring them in main()
and then using them in a loop, and I don't understand why this error is occurring. I would greatly appreciate any help in understanding the issue and how to fix it.
#include <iostream>
using namespace std;
int main() {
sum = 0;
value = 0;
while(value > -1){
sum += value;
cout << "Enter a value" << endl;
cin >> value;
}
return 0;
}