Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


My first c++ program

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Tue May 15, 2007 2:36 am    Post subject: My first c++ program Reply with quote

I'm Pyro the Noob and this is my first c++ program i have made by myself no book giving me source code. I might of messed up the gravitational formula.


The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.


_________________

Earthbound = 31337
Back to top
View user's profile Send private message
kennny2004
Advanced Cheater
Reputation: 0

Joined: 22 Jan 2006
Posts: 59
Location: Canada

PostPosted: Tue May 15, 2007 3:23 pm    Post subject: Reply with quote

what it does, not up for getting more staff on my desktop lol mabie post the source
_________________
Hey was up! lol, simple heh
Back to top
View user's profile Send private message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Tue May 15, 2007 7:37 pm    Post subject: Reply with quote

Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// declaring variables
double M1;
double M2;
double Distance;
double G;
double Answer;
int Filler;
//The messages and storing variables
cout << "What is the First objects mass: ";
cin >> M1;

cout << "What is the second objects mass: ";
cin >> M2;

cout << "What is the distance between the centers of gravity of the two objects: ";
cin >> Distance;

//Here im doing the math
Answer =(G * M1 * M2)/(Distance * Distance);
G = 6.67300;
//And now i print the answer
cout << "The answer is: " << Answer <<  endl;
cout << "This program was made by " << "Pyro";
cin >> Filler;
return 0;
}


It is a simple program for gravitational force calculation I hope I set up the math correctly.

_________________

Earthbound = 31337
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Tue May 15, 2007 8:33 pm    Post subject: Reply with quote

You probably should set the constant G before you use it.
_________________

Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for?
Back to top
View user's profile Send private message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Wed May 16, 2007 12:50 am    Post subject: Reply with quote

Alright i fixed my code so it should actually work now.

Here is my source code.


Code:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
// declaring variables
double dM1;
double dM2;
double dDistance;
double dAnswer;
double dFiller;
double dG;
double dA;
double dB;
// The constant for gravity
dG = 6.673;
//The messages and storing variables
cout << "What is the First objects mass: ";
cin >> dM1;

cout << "What is the second objects mass: ";
cin >> dM2;

cout << "What is the distance between the centers of gravity of the two objects: ";
cin >> dDistance;

//Here im doing the math
dA = dDistance * dDistance;
dB = dG * dM1 * dM2;
dAnswer = dB/dA;
//And now i print the answer
cout << "The answer is: " << dAnswer <<  endl;
cout << "This program was made by " << "Me";
cin >> dFiller;
return 0;
}



The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.


_________________

Earthbound = 31337
Back to top
View user's profile Send private message
TheSorc3r3r
I post too much
Reputation: 0

Joined: 06 Sep 2006
Posts: 2404

PostPosted: Wed May 16, 2007 4:40 am    Post subject: Reply with quote

Here's a revised version (although I don't think that formula/constant is right.. what do I know!? I just learned Inertia Razz )

Code:
#include <iostream>
using namespace std;

#define GRAVITY 6.673

int main()
{
double mass1 = 0, mass2 = 0, distance = 0;

cout << "GravityCalculator\nby LosPlagos"
<< "\n\nEnter the first object's mass: ";
cin >> mass1;
cout << "\nEnter the second object's mass: ";
cin >> mass2;
cout << "\nEnter the distance between each objects' center of gravity: ";
cin >> distance;

if (!(mass1 & mass2 & distance))
{
cout << "\nError:  You didn't enter something correctly."
return 1;
}

cout << "\nAnswer is: " << (GRAVITY * mass1 * mass2)/(distance) << endl;
return 1;
}

_________________


Don't laugh, I'm still learning photoshop!


Last edited by TheSorc3r3r on Wed May 16, 2007 7:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Wed May 16, 2007 4:46 am    Post subject: Reply with quote

The gravatational constant is probly wrong since i did it all from memory.
Also i just started learning if commands.

_________________

Earthbound = 31337
Back to top
View user's profile Send private message
D@ntheman
How do I cheat?
Reputation: 0

Joined: 14 Dec 2006
Posts: 2

PostPosted: Wed May 16, 2007 9:00 am    Post subject: Reply with quote

Thats a fine looking program you've made ther.
_________________
not a 1337 haxor!
Back to top
View user's profile Send private message
the_undead
Expert Cheater
Reputation: 1

Joined: 12 Nov 2006
Posts: 235
Location: Johannesburg, South Africa

PostPosted: Wed May 16, 2007 9:07 am    Post subject: Reply with quote

Dont make gravity a constant concidering some of us use 9.98m/s^2 as the value.
_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Wed May 16, 2007 10:10 am    Post subject: Reply with quote

the_undead wrote:
Dont make gravity a constant concidering some of us use 9.98m/s^2 as the value.


The gravitaional constant (G) is 6.67e-11.
9.81m/s^2 is the acceleration caused by Earth's gravity.

Also:
Your formula is incorrect.
Fg = (G(m1)(m2))/(R^2) Is the correct one.
Back to top
View user's profile Send private message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Wed May 16, 2007 6:44 pm    Post subject: Reply with quote

Flyte wrote:
the_undead wrote:
Dont make gravity a constant concidering some of us use 9.98m/s^2 as the value.


The gravitaional constant (G) is 6.67e-11.
9.81m/s^2 is the acceleration caused by Earth's gravity.

Also:
Your formula is incorrect.
Fg = (G(m1)(m2))/(R^2) Is the correct one.


Could you explain what r^2 is since the formula I remember is g*m1*m2/d^2 and is what I used. The current formula im using has these lines of code now.

Code:

dG = 6.67e-11;
dA = dDistance*dDistance;
dB = dG * dM1 * dM2;


_________________

Earthbound = 31337
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu May 17, 2007 2:55 pm    Post subject: Reply with quote

Losplagos wrote:
Flyte wrote:
the_undead wrote:
Dont make gravity a constant concidering some of us use 9.98m/s^2 as the value.


The gravitaional constant (G) is 6.67e-11.
9.81m/s^2 is the acceleration caused by Earth's gravity.

Also:
Your formula is incorrect.
Fg = (G(m1)(m2))/(R^2) Is the correct one.


Could you explain what r^2 is since the formula I remember is g*m1*m2/d^2 and is what I used. The current formula im using has these lines of code now.

Code:

dG = 6.67e-11;
dA = dDistance*dDistance;
dB = dG * dM1 * dM2;



Sorry, I didn't notice that you did square the radius in the code by multiplying.

R and d are the same, just different variables.
R (Radius)
d (distance)
Back to top
View user's profile Send private message
krndandaman
Cheater
Reputation: 0

Joined: 11 Nov 2006
Posts: 26

PostPosted: Thu May 17, 2007 5:12 pm    Post subject: Reply with quote

How'd you learn this?
Its a cool program.
From highschool class?
If its from a webtut, could you PM me a link?
If you could, that'd be great.
thanks in advance!

_________________
I'm mainly focused on GameCheetah sorry if I'm not here often.
A Wise man once said:"Beware of 'cute' people on MS cause anybody, including 50 year old men, can be 'cute' in MS."
Back to top
View user's profile Send private message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Thu May 17, 2007 7:15 pm    Post subject: Reply with quote

No class just what i have learned so far all I have used to make this you could learn in a day of c++ learning you could do the same.
_________________

Earthbound = 31337
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites