#include <iostream>
usingnamespace std;
int main() {
// Written by: Joe Vardaman
// Computes the average of a set of values entered by the user, e.g. with
// 10.0 5.0 6.0 9.0 0.0
// the average is 7.5
int count;
float number, runningTotal ;
runningTotal = 0;
count = 0;
cout << "Type the numbers, the last being 0";
cin >> number;
while (number != 0) {
runningTotal = runningTotal + number;
count = count + 1;
cin >> number;
}
cout << "The average of the " << count << "numbers is " << runningTotal/count;
}
Hi @jvardam,
I've seen that problem before, but it really depends on multiple things.
If you have a .c file, then it's not c++, therefore it does not have the iostream library available.
If you work with borland, I think it requires you to include with "iostream.h".
If neither of the above describes your situation, then I don't know what.
Hope I've been at least a little help.
P.S.: I just saw the name of the file in the title. It says "newfile.c", but if you change it to "newfile.cpp", it might work.
when i run it now that i changed the name there are a bunch of problems with it and this is the output:
cd 'C:\Users\josep\OneDrive\Documents\NetBeansProjects\project.cpp'
C:\MINGW\32\mingw32\msys\1.0\bin\make.exe -f Makefile CONF=Debug
"/C/MINGW/32/mingw32/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/josep/OneDrive/Documents/NetBeansProjects/project.cpp'
"/C/MINGW/32/mingw32/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/project.cpp.exe
make.exe[2]: Entering directory `/c/Users/josep/OneDrive/Documents/NetBeansProjects/project.cpp'
mkdir -p build/Debug/MinGW-Windows
rm -f "build/Debug/MinGW-Windows/newfile.o.d"
g++ -c -g -MMD -MP -MF "build/Debug/MinGW-Windows/newfile.o.d" -o build/Debug/MinGW-Windows/newfile.o newfile.cpp
newfile.cpp: In function 'int main()':
newfile.cpp:21:82: error: expected '}' at end of input
cout << "The average of the " << count << "numbers is " << runningTotal/count;
^
make.exe[2]: *** [build/Debug/MinGW-Windows/newfile.o] Error 1
make.exe[2]: Leaving directory `/c/Users/josep/OneDrive/Documents/NetBeansProjects/project.cpp'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/josep/OneDrive/Documents/NetBeansProjects/project.cpp'
make.exe": *** [.build-impl] Error 2