Code help, language discussions, and software development advice.
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
I know that when using this code:
that it increases x by 1, but what code would I use to increase x by 10, or by 0.1?
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
-
Contact:
Post
by Smartweb »
x *= 10, x *= 0.1.
For the second to work x has to be a double.
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
i don't understand, where would I place that code
would I replace
with
to increase by a factor of 10?
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
-
Contact:
Post
by Smartweb »
right
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
so, if C was a constant, could I use:
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
i have used your code, and my output is always zero for this program
Code: Select all
#include <iostream>
int main ()
{
double C=299792458;
double X=0;
double Y=0;
double V=0;
/*
V=(V1+V2)/(1+((V1*V2)/(C^2)))
*/
while (X<C)
{
cout<<"V1="<<X<<"\n";
cout<<"V="<<(X+X)/(1+((X*X)/(C*C)))<<"\n";
X*=0.1*C;
}
return 0;
}
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
-
Contact:
Post
by Smartweb »
I'm not a C++ expert. Often C++ doesn't do quite as you like it to.
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
ha, could you do what I'm trying to do in c++ in VB?
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
-
Contact:
Post
by Smartweb »
The result would be more predictable, but it woudl take a little bit longer.
-
Tebow2000
- Registered User
- Posts: 1099
- Joined: January 19th, 2004, 7:56 am
- Location: New Orleans, Louisiana
-
Contact:
Post
by Tebow2000 »
lol he probably could
Redcode Hosting
redcodehosting.com | Unix Shared Hosting | sales[aT]redcodehosting[dOt]com
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
Smartweb wrote:The result would be more predictable, but it woudl take a little bit longer.
that is why C++ > VB
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
-
Contact:
Post
by Smartweb »
VB's advantage is that the result is predictable. And GUI's are a lot easier.
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
but c++ has faster/more efficent code and is better for a heavy math environment
-
Smartweb
- Registered User
- Posts: 622
- Joined: January 15th, 2004, 2:11 am
-
Contact:
Post
by Smartweb »
I like C++'s portability more than anything. I can write a program in Windows that I can compile in Linux with no changes.
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
and there are free compilers you can get for c++ legally
-
ccb056
- Site Administrator
- Posts: 981
- Joined: January 14th, 2004, 11:36 pm
- Location: Texas
-
Contact:
Post
by ccb056 »
here is the code for increasing x by y