| | |
Help - Expected Primary-Expression and ";"
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 36
Reputation:
Solved Threads: 0
Here is my code:
And I get there two errors. Any ideas?
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
const double e = 2.71828;
double t, f, n, B, VoltageGain;
cout << "Please enter the time in hours the culture has been refrigerated: ";
cin >> t;
cout << endl;
while (t < 0)
{
cout << "t cannot be a negative value." << endl << endl;
cout << "Please enter the time in hours the culture has been refrigerated: ";
cin >> t;
}
B = 300,000 * pow(e, -0.032 * t);
cout << fixed << showpoint;
cout << "The number of bacteria in the culture after " << setprecision(6) << t << " hours of refrigeration is " << setprecision(6) << B << endl;
cout << "Please enter the amplifier's frequency in Hertz: ";
cin >> f;
cout << endl;
while (f < 0)
{
cout << "f cannot be a negative value." << endl << endl;
cout << "Please enter the amplifier's frequency in Hertz: ";
cin >> f;
}
cout << "Please enter the number of stages in the amplifier: ";
cin >> n;
cout << endl;
while (n < 0)
{
cout << "n cannot be a negative value." << endl << endl;
cout << "Please enter the number of stages in the amplifier: ";
cin >> n;
}
VoltageGain = double pow ((275 / sqrt (pow (23, 2) + 0.5 * pow (f, 2))), n);
cout << fixed << showpoint;
cout << "The voltage gain of an amplifier with a frequency of " << setprecision(6) << f << " and with " << setprecision(6) << n
<< " stages is " << setprecision(6) << VoltageGain << endl;
return 0 ;
}And I get there two errors. Any ideas?
(15): g++ assignment2.cpp assignment2.cpp: In function 'int main()': assignment2.cpp:98: error: expected primary-expression before 'double' assignment2.cpp:98: error: expected `;' before 'double'
•
•
Join Date: Sep 2009
Posts: 36
Reputation:
Solved Threads: 0
•
•
•
•
Taking a stab at guessing line 98
VoltageGain = double pow ((275 / sqrt (pow (23, 2) + 0.5 * pow (f, 2))), n);
What does double do here?
g++ assignment2.cpp assignment2.cpp: In function 'int main()': assignment2.cpp:98: error: call of overloaded 'pow(int, int)' is ambiguous /usr/include/iso/math_iso.h:63: note: candidates are: double pow(double, double) /auto/usc/gnu/gcc/4.2.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.2.1/../../../../include/c++/4.2.1/cmath:373: note: long double std::pow(long double, int) /auto/usc/gnu/gcc/4.2.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.2.1/../../../../include/c++/4.2.1/cmath:369: note: float std::pow(float, int) /auto/usc/gnu/gcc/4.2.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.2.1/../../../../include/c++/4.2.1/cmath:365: note: double std::pow(double, int) /auto/usc/gnu/gcc/4.2.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.2.1/../../../../include/c++/4.2.1/cmath:361: note: long double std::pow(long double, long double) /auto/usc/gnu/gcc/4.2.1/bin/../lib/gcc/sparc-sun-solaris2.10/4.2.1/../../../../include/c++/4.2.1/cmath:357: note: float std::pow(float, float)
pow (23, 2)
You're passing two integers.
> 'pow(int, int)' is ambiguous
two integers is confusing....
> double std::pow(double, int)
A variety of combinations involving floating point types is offered.
Pick one, and make an appropriate constant a float (of whatever type).
You're passing two integers.
> 'pow(int, int)' is ambiguous
two integers is confusing....
> double std::pow(double, int)
A variety of combinations involving floating point types is offered.
Pick one, and make an appropriate constant a float (of whatever type).
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
--
If your code lacks code tags, you will be IGNORED
--
If your code lacks code tags, you will be IGNORED
•
•
Join Date: Sep 2009
Posts: 36
Reputation:
Solved Threads: 0
•
•
•
•
pow (23, 2)
You're passing two integers.
> 'pow(int, int)' is ambiguous
two integers is confusing....
> double std::pow(double, int)
A variety of combinations involving floating point types is offered.
Pick one, and make an appropriate constant a float (of whatever type).
![]() |
Similar Threads
- Expected primary-expression issue (C++)
- please help with code >> expected primary-expression? (C++)
- expected primary expression error (C++)
- expected init-declarator (C++)
- Epected Primary Errors (C++)
- Compile errors [help] [ log ] (C++)
- Errors with membering functions in a class (C++)
Other Threads in the C++ Forum
- Previous Thread: can't seem to find anything about file protection in C++?
- Next Thread: Why can't i find out length of my file?
Views: 687 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C++
algorithm api array arrays assignment basic beginner binary browser c++ c/c++ calculator char class classes code compile compiler console constructor conversion convert count delete desktop dll dynamic encryption error file files form fstream function functions game givemetehcodez graph gui homework i/o iamthwee input int lazy library linker list loop loops math matrix member memory network newbie number numbers object objects opengl operator output parameter pointer pointers problem program programming project random read recursion recursive reference sort sorting spoonfeeding string strings struct student studio template templates text time tree undefined variable vc++ vector video visual visualstudio void win32 window windows winsock






