This is wrong:
cin >> a, b;
It should be:
cin >> a >> b;
Likewise:
cin >> c, d, e;
should be:
cin >> c >> d >> e;
Make sure you enable compiler warnings in future - that way the compiler can point out many simple mistakes like this for you. When I compile your original code with warnings enabled I get:
$ g++ -Wall junk.cpp
junk.cpp:5:1: error: 'main' must return 'int'
void main(void)
^~~~
int
junk.cpp:13:11: warning: expression result unused [-Wunused-value]
cin >> c, d, e;
^
junk.cpp:11:11: warning: expression result unused [-Wunused-value]
cin >> a, b;
^
junk.cpp:13:14: warning: expression result unused [-Wunused-value]
cin >> c, d, e;
^
3 warnings and 1 error generated.
From this it's easy to see that there is something wrong with the two cin
lines, and that you also need to change the return type of main
to int
.