#include <iostream>
#include <iomanip>
using namespace std;
int calculate ()
{
double a;
double b;
a =(3.0);
b =(5.0);
cout << " " << fixed << setprecision (1) << a << "\n" << endl;
cout << "* " << fixed << setprecision (1) << b << "\n" << endl;
cout << "------" << endl;
cout << fixed << setprecision (2) << a*b << "\n" << endl;
system("PAUSE");
return 0;
}
int calculate(int a, int b, int c)
{
double a;
double b;
double c;
a =(7.1);
b =(8.3);
c =(2.2);
cout << " " << fixed << setprecision (1) << a << "\n" << endl;
cout << "* " << fixed << setprecision (1) << b << "\n" << endl;
cout << "- " << fixed << setprecision (1) << c << "\n" << endl;
cout << "------" << endl;
cout << fixed << setprecision (2) << (a*b)-c << "\n" << endl;
system("PAUSE");
return 0;
}
Question: Why do I have to change doubles--->ints? Does anything standout that is wrong?
Here is the output: 1>------ Build started: Project: HW1-2, Configuration: Debug Win32 ------ 1> HW1-2.cpp 1>c:\users\asus\desktop\hw1-2\hw1-2\hw1-2.cpp(21): error C2082: redefinition of formal parameter 'a' 1>c:\users\asus\desktop\hw1-2\hw1-2\hw1-2.cpp(22): error C2082: redefinition of formal parameter 'b' 1>c:\users\asus\desktop\hw1-2\hw1-2\hw1-2.cpp(23): error C2082: redefinition of formal parameter 'c' 1>c:\users\asus\desktop\hw1-2\hw1-2\hw1-2.cpp(24): warning C4244: '=' : conversion from 'double' to 'int', possible loss of data 1>c:\users\asus\desktop\hw1-2\hw1-2\hw1-2.cpp(25): warning C4244: '=' : conversion from 'double' to 'int', possible loss of data 1>c:\users\asus\desktop\hw1-2\hw1-2\hw1-2.cpp(26): warning C4244: '=' : conversion from 'double' to 'int', possible loss of data ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========