Integer Division by Zero?

I am supposed to calculate the combined resistance of 3 resistor in parallel to two decimal places. The formula for this is 1/(1/R1+1/R2+1/R3). Every time I try to run my program I get Unhandled exception at 0x0006507A in glavin_lab2.exe: 0xC0000094: Integer division by zero. My teacher said there might be a problem with my formula code but I don't know what I'm doing wrong.

//This program calculates the combined resistance when the three resistors are attached in parallel
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
double combinedResistance;
int R1, R2, R3;

R1 = 1000;
R2 = 1000;
R3 = 1000;
combinedResistance = 1 / (1/R1 + 1/R2 + 1/R3);

cout << setprecision(2) << fixed;
cout << "The combined resistance is" << combinedResistance << "ohms" << endl;

system("pause");
return 0;
}
When you divide two integers you will get an integer (the decimal part is lost).

1/R1 -> 1/1000 -> 0

Consider using floating-point values.
1/x where x > 1 is 0 in integer division. You'll want to have them as doubles instead probably.
Simplest solution:

declare R1, R2, R3 as double instead of int.
double R1, R2, R3;
I changed it to double so now I have

//This program calculates the combined resistance when the three resistors are attached in parallel
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
double combinedResistance, R1, R2, R3;

R1 = 1000;
R2 = 1000;
R3 = 1000;
combinedResistance = 1 / (1/R1 + 1/R2 + 1/R3);

cout << setprecision(2) << fixed;
cout << "The combined resistance is" << combinedResistance << "ohms" << endl;

system("pause");
return 0;
}

But now I'm getting this:

'glavin_lab2.exe' (Win32): Loaded 'C:\Users\amglavin\Documents\C.S. Assignments\glavin_lab2\Debug\glavin_lab2.exe'. Symbols loaded.
'glavin_lab2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Cannot find or open the PDB file.
'glavin_lab2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Cannot find or open the PDB file.
'glavin_lab2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Cannot find or open the PDB file.
'glavin_lab2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcp110d.dll'. Symbols loaded.
'glavin_lab2.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcr110d.dll'. Symbols loaded.
Application "\??\C:\Windows\system32\cmd.exe" found in cache
The program '[7784] glavin_lab2.exe' has exited with code 0 (0x0).
Topic archived. No new replies allowed.