-
November 13th, 2011, 10:29 PM
#1
calculate log
how to do function to calc:
a = log b / log c(1-d)
if user need to input b, c and d?
tq.
-
November 13th, 2011, 10:54 PM
#2
Re: calculate log
Originally Posted by hawtchocolate
if user need to input b, c and d?
Do you know how to call C++ functions? Then the function you want is in <cmath>.
http://www.cplusplus.com/reference/clibrary/cmath/log/
Regards,
Paul McKenzie
-
November 18th, 2011, 07:46 AM
#3
Re: calculate log
a = (log10 (b)) / (log10 (C*(1-d)) );
i try dis but i stil cant get the value of a. any help?
tq
-
November 18th, 2011, 07:56 AM
#4
Re: calculate log
What do you mean by "cant get the value of a"?
Victor Nijegorodov
-
November 18th, 2011, 08:05 AM
#5
Re: calculate log
it display nothing when i compiled;
n = *nothing here.
the equation is correct or not? =.='
-
November 18th, 2011, 08:09 AM
#6
Re: calculate log
#include <iostream>
#include <math.h>
int main ()
{
float S, n, C, d;
cout << "Please enter S value :";
cin >> S ;
cout << "Please enter C value :";
cin >> C;
cout << "Please enter d value :";
cin >> d;
n = (log10 (S)) / (log10 (C*(1-d)) );
printf ("n = ", n );
return 0;
}
dis is what i tried. =.=
-
November 18th, 2011, 08:16 AM
#7
Re: calculate log
Originally Posted by hawtchocolate
Code:
#include <iostream>
#include <math.h>
int main ()
{
float S, n, C, d;
...
n = (log10 (S)) / (log10 (C*(1-d)) );
printf ("n = ", n );
return 0;
}
You must specify the format (like %f) to print your variable. See examples (and description) in printf, wprintf article.
Victor Nijegorodov
-
November 18th, 2011, 08:20 AM
#8
Re: calculate log
thanx for ur fast reply.im quite new in c++.
whats the different if i use
cout << "n = " << n ;
??
n one more thing when i compiled, it said
" 'cout' was not declared in this scope "
-
November 18th, 2011, 08:25 AM
#9
Re: calculate log
Originally Posted by hawtchocolate
whats the different if i use
cout << "n = " << n ;
cout and operator << when given a double knows how to display it to the console. There is no format specifier necessary.
n one more thing when i compiled, it said
" 'cout' was not declared in this scope "
Have you written a basic "Hello World" program in C++?
Code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World";
}
This compiles and runs.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|