K
Kensai
I get these two errors on VC++ EE.
(13): error C2065: 'ratio' : undeclared identifier
(19): error C2065: 'ratio' : undeclared identifier
in one of my first exercises (Chapter 3, Programming by Stroustrup):
#include "../../std_lib_facilities.h"
// two values comparison
int main()
{
cout << "Please enter two integer values.\n";
int val1; int val2;
cin >> val1 >> val2;
if (val1>val2)
double ratio = val1/val2;
cout << "The first value is larger than the second. Their sum is " <<
val1+val2 << ". "
<< "Their difference is " << val1-val2 << ". "
<< "Their product is " << val1*val2 << ". "
<< "The ratio of these values is " << ratio << ".\n";
if (val1<val2)
double ratio = val2/val1;
cout << "The second value is larger than the first. Their sum is " <<
val1+val2 << ". "
<< "Their difference is " << val2-val1 << ". "
<< "Their product is " << val1*val2 << ". "
<< "The ratio of these values is " << ratio << ".\n";
if (val1==val2)
cout << "The first value is equal to the second. Their sum is " <<
val1+val2 << ". "
<< "Their difference is 0. "
<< "Their product is " << val1*val2 << ". "
<< "The ratio of these values is 1.\n";
keep_window_open(); // wait for a character to be entered
return 0;
}
Why? I just want to do the division using a double type to have a better
ratio. Why is the compiler complaining?
(13): error C2065: 'ratio' : undeclared identifier
(19): error C2065: 'ratio' : undeclared identifier
in one of my first exercises (Chapter 3, Programming by Stroustrup):
#include "../../std_lib_facilities.h"
// two values comparison
int main()
{
cout << "Please enter two integer values.\n";
int val1; int val2;
cin >> val1 >> val2;
if (val1>val2)
double ratio = val1/val2;
cout << "The first value is larger than the second. Their sum is " <<
val1+val2 << ". "
<< "Their difference is " << val1-val2 << ". "
<< "Their product is " << val1*val2 << ". "
<< "The ratio of these values is " << ratio << ".\n";
if (val1<val2)
double ratio = val2/val1;
cout << "The second value is larger than the first. Their sum is " <<
val1+val2 << ". "
<< "Their difference is " << val2-val1 << ". "
<< "Their product is " << val1*val2 << ". "
<< "The ratio of these values is " << ratio << ".\n";
if (val1==val2)
cout << "The first value is equal to the second. Their sum is " <<
val1+val2 << ". "
<< "Their difference is 0. "
<< "Their product is " << val1*val2 << ". "
<< "The ratio of these values is 1.\n";
keep_window_open(); // wait for a character to be entered
return 0;
}
Why? I just want to do the division using a double type to have a better
ratio. Why is the compiler complaining?