i made a simple script to find total resistance through a parallel circuit on a friend's computer. i compiled it using Dev C++ 4 and it worked perfectly. i sent the code to my own computer and using the same compiler, Dev C++ 4, it absolutely refused to compile on my computer. look at this code
PHP Code:
#include <iostream.h>
#include <stdlib.h>
int main() {
int n = 1; //resistor number
float resistor; //resistance of a given resister
float reciprical_sum = 0; //sum of resistance recipricals
float resistance; //total resistance, reciprical of reciprical_sum
cout << "enter resistance, enter 0 to quit \n";
while (resistor !=0) {
_ _ cout << "resistor " << n << ": ";
_ _ cin >> resistor;
_ _ if (resistor != 0) {
_ _ _ _reciprical_sum += (1 / resistor);
_ _ }
_ _ cout << "\n";
_ _ ++n;
}
resistance = (1 / reciprical_sum);
out << "total resistance: " << resistance << "\n";
system("PAUSE");
return 0;
}
here are the errors
10 c:\dev-c_~1\parall~1.cpp
parse error before character 0240
18 c:\dev-c_~1\parall~1.cpp
ANSI C++ forbids declaration `resistance' with no type
18 c:\dev-c_~1\parall~1.cpp
`reciprical_sum' was not declared in this scope
19 c:\dev-c_~1\parall~1.cpp
syntax error before `<'
20 c:\dev-c_~1\parall~1.cpp
ANSI C++ forbids declaration `system' with no type
20 c:\dev-c_~1\parall~1.cpp
`int system' redeclared as different kind of symbol
283 c:\dev-c_~1\include\stdlib.h
previous declaration of `int system(const char *)'
20 c:\dev-c_~1\parall~1.cpp
initialization to `int' from `const char *' lacks a cast
21 c:\dev-c_~1\parall~1.cpp
parse error before `return'
notice the line in bold. Dev C++ tried to tell me that even one of the include files is wrong.
ok windows is a POS because every time i try to paste stuff from my source file, it keeps putting underscores into my post!!!!
just disregard all underscores in that posted code except for one of the float names.