Sheila
2007-11-04 22:35:23 UTC
I corrected one error (else cout << Invalid input" << endl; changed to
else cout << "Invalid input" << endl;) but there are still three errors
as follows:
C:\TC\DATA>bcc32 totals.cpp
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
TOTALS.CPP:
Error E2451 TOTALS.CPP 7: Undefined symbol 'not' in function main()
Error E2377 TOTALS.CPP 7: While statement missing ) in function main()
Error E2054 TOTALS.CPP 17: Misplaced else in function main()
Warning W8004 TOTALS.CPP 18: 'total' is assigned a value that is never
used in f
unction main()
*** 3 errors in Compile ***
Thank you
else cout << "Invalid input" << endl;) but there are still three errors
as follows:
C:\TC\DATA>bcc32 totals.cpp
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
TOTALS.CPP:
Error E2451 TOTALS.CPP 7: Undefined symbol 'not' in function main()
Error E2377 TOTALS.CPP 7: While statement missing ) in function main()
Error E2054 TOTALS.CPP 17: Misplaced else in function main()
Warning W8004 TOTALS.CPP 18: 'total' is assigned a value that is never
used in f
unction main()
*** 3 errors in Compile ***
Thank you
I have just written a simple CPP program but it does not compile using
// *****************************************************************************
#include <iostream>
using namespace std;
int main()
{
bool finished = false;
int total = 0;
while (not finished)
{
int num;
cin >> num;
if (cin.fail())
finished = true;
else total = total + num;
}
if (cin.eof())
cout << "Total is " << total << endl;
else cout << Invalid input" << endl;
}
// *****************************************************************************
Any ideas what could be the problem? I have managed to test my
installation by typing a simple hello, world program but this particular
one does not work!!
// *****************************************************************************
#include <iostream>
using namespace std;
int main()
{
bool finished = false;
int total = 0;
while (not finished)
{
int num;
cin >> num;
if (cin.fail())
finished = true;
else total = total + num;
}
if (cin.eof())
cout << "Total is " << total << endl;
else cout << Invalid input" << endl;
}
// *****************************************************************************
Any ideas what could be the problem? I have managed to test my
installation by typing a simple hello, world program but this particular
one does not work!!