The task: to find the arithmetic mean of 10 random numbers ranging from 1 to 40. The problem is that they do not want to compile after adding this line here sum += r; .
#include "pch.h" #include <iostream> #include <iomanip> using namespace std; int main() { int i, r, sum; srand(time(NULL)); for (i = 1; i <= 10; i++) { r = 1 + rand() % (40 - 1); sum += r; cout << r << endl; } cout << "Average" << sum/10; }