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 


Only people dat know C++ come in?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
favoritio
Expert Cheater
Reputation: 0

Joined: 09 Sep 2006
Posts: 111
Location: USA 4 life the g cove state not saying

PostPosted: Wed Mar 14, 2007 5:05 pm    Post subject: Only people dat know C++ come in? Reply with quote

tell me how good my calculator code is from 1 - 10. Lol. Im trying to learn C++ so I can make $$$$ and hack ms so bad lol. And also I wanna learn how to add a square root function so I can find square roots of numbers. Thanks
Code:
 

#include <iostream>
using namespace std;
int main ()
{

//This is my calculator which will do every calculation in a second of two numbers only

int a;                  //Declaring my first whole number variable
int b;                  //Declaring my second whole number variable
int c;                  //Just a trick to distract while lol so dat my program may continue
double d;               //Declaring my first decimal varible
double e;               //Declaring my second decimal variable
int diff;               //Allowing me to do subtraction with whole numbers
int sum;               //Allowing me to do addition   with whole numbers
int product;            //Allowing me to do multiplication   with whole numbers
int quotient;            //Allowing me to do division      with whole numbers
double diffd;            //Allowing me to do subtraction      with decimals
double sumd;            //Allowing me to do addition      with decimals
double productd;         //Allowing me to do multiplication   with decimals
double quotientd;         //Allowing me to do division      with decimals
double firstsquare;         //Allowing me to have my first whole number squared;
double secondsquare;      //Allowing me to have my second whole number squared
double firstsquared;      //Allowing me to have my first decimal number squared;
double secondsquared;      //Allowing me to have my second decimal number squared

   
cout<<" Always read this before continuing thanks for your time. Please type in the number 1 or a higher number and den press enter so dat you can use my calculator dat is the code to be able to use my calculator so if you dont do this you will not use my calculator. Oh yeah and dont forget to type in the number 1 or a higher number and then press enter to use my calculator lol.";
cin>>c;
while (c >= -1000000) {
   cout<<"This calculator will do the calculation of two numbers in a second \n";
   cout<<" If you want to use decimals type in da number 1 and then press enter \n";
   cout<<"Please enter your first whole number ";
   cin>>a;
   if (a >= 2) {
   cout<<" The number you just entered was " <<a<< "\n";
   cout<<" Please enter your second whole number ";
   cin>>b;
   cout<<" The number you just entered was " <<b<< "\n";
   sum = a + b;
   product = a * b;
   firstsquare = a * a;
   secondsquare = b * b;
   
   
   if (a > b) {
      diff = a - b;
   }
   else {
      diff = b - a;
   }
      
   if (a > b) {
      quotient = a / b;
   }
   else {
      quotient = b / a;
   }

   cout<<" The sum of your numbers is " <<sum<< "\n" " The diference of your numbers is " <<diff<< "\n" " The quotient of your numbers is " <<quotient<< "\n" " The product of your numbers is " <<product<< "\n";
   cout<< a<< " squared is " <<firstsquare<< "\n";
   cout<< b<< " squared is " <<secondsquare<< "\n";
   }
   
   else if (a <= 1) {
      cout<<" Please enter your first decimal ";
      cin>>d;
      cout<<" The number you just entered is " <<d<< "\n";
      cout<<" Please enter your second decimal number ";
      cin>>e;
      cout<<" The number you just entered is " <<e<< "\n";
      productd = d * e;
      sumd = d + e;
      firstsquared = d * d;
   secondsquared = e * e;

   
      if (d > e) {
      diffd = d - e;
   }
   else {
      diffd = e - d;
   }
      
   if (d > e) {
      quotientd = d / e;
   }
   else {
      quotientd = e / e;
   }
   
   cout<<" The sum of your numbers is " <<sumd<< "\n" " The diference of your numbers is " <<diffd<< "\n" " The quotient of your numbers is " <<quotientd<< "\n" " The product of your numbers is " <<productd<< "\n";
   cout<< d<< " squared is " <<firstsquared<< "\n";
   cout<< e<< " squared is " <<secondsquared<< "\n";
      
}
   }
   }


Last edited by favoritio on Thu Mar 15, 2007 6:59 pm; edited 1 time in total
Back to top
View user's profile Send private message
Aetherine
Master Cheater
Reputation: 0

Joined: 07 Mar 2007
Posts: 278
Location: The place you'd least expect me.

PostPosted: Wed Mar 14, 2007 5:10 pm    Post subject: Reply with quote

It's a little messy with the cout's. Don't be afraid to use multiple cout's to make it more organized.

Also, I believe there's a function for getting a square root.
http://www.cplusplus.com/reference/clibrary/cmath/sqrt.html

_________________
ᆲᅨᆰ예ᄈ￞ᆵᆬ○ᆭᆵ'￿ᅨ¦ᅮ¥￰￷￞ᅮ.ᅨ>=$
Back to top
View user's profile Send private message
Devv
Expert Cheater
Reputation: 0

Joined: 21 Jan 2006
Posts: 173

PostPosted: Wed Mar 14, 2007 5:14 pm    Post subject: Reply with quote

Yayyyy! Someone learning C++. Well, the math lib has pretty much all the functions you need but I guess you want a challenge.

Try using strings to calculate from since int's are limited. Make your own functions and start at the bottom (add) and work your way up. Wink

Add some cool ascii graphic picture of a calculator for startup. Add some help commands -h for help -a for about -s for syntax etc. I also suggest that you use argv, argc for input. (If you can use them)

[EDIT]Int main is a good start of every program!

_________________
Back to top
View user's profile Send private message
favoritio
Expert Cheater
Reputation: 0

Joined: 09 Sep 2006
Posts: 111
Location: USA 4 life the g cove state not saying

PostPosted: Wed Mar 14, 2007 5:26 pm    Post subject: Reply with quote

I dont know how to make a graphic picture of a calculator or any of those graphic things. I only can write programs. Lol
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed Mar 14, 2007 5:33 pm    Post subject: Reply with quote

instead of:

Code:

double 1;
double 2;
double 3;


try:
Code:

double 1, 2, 3;


Faster and smaller.
Back to top
View user's profile Send private message MSN Messenger
favoritio
Expert Cheater
Reputation: 0

Joined: 09 Sep 2006
Posts: 111
Location: USA 4 life the g cove state not saying

PostPosted: Wed Mar 14, 2007 5:35 pm    Post subject: Reply with quote

noz3001 wrote:
instead of:

Code:

double 1;
double 2;
double 3;


try:
Code:

double 1, 2, 3;


Faster and smaller.



oh yea that is lol didnt think about that thanks noz.
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Thu Mar 15, 2007 8:28 am    Post subject: Reply with quote

Devv wrote:
Yayyyy! Someone learning C++. Well, the math lib has pretty much all the functions you need but I guess you want a challenge.

Try using strings to calculate from since int's are limited. Make your own functions and start at the bottom (add) and work your way up. Wink

Add some cool ascii graphic picture of a calculator for startup. Add some help commands -h for help -a for about -s for syntax etc. I also suggest that you use argv, argc for input. (If you can use them)

[EDIT]Int main is a good start of every program!


Ha, challenge? 2 * 2?
Back to top
View user's profile Send private message MSN Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu Mar 15, 2007 10:15 am    Post subject: Reply with quote

It looks really messy, but I suppose it will do what you need. Remember to stick a:

Code:
return;


At the end of the function, since a non-void function should have a return at the end.
Back to top
View user's profile Send private message
DeltaFlyer
Grandmaster Cheater
Reputation: 0

Joined: 22 Jul 2006
Posts: 666

PostPosted: Thu Mar 15, 2007 7:50 pm    Post subject: Reply with quote

You know.... doubles can hold numbers larger than 1...
_________________

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
BlackKilla
Expert Cheater
Reputation: 0

Joined: 02 Jul 2006
Posts: 207
Location: North America ~Rollin up the Trees...

PostPosted: Fri Mar 16, 2007 3:03 pm    Post subject: Reply with quote

I would give it say an 7,But the thiang with square roots,Look at this to get a prospective on it

Code:

The square root of a number is just the number which when multiplied by itself gives the first number. So 2 is the square root of 4 because 2 * 2 = 4.

Start with the number you want to find the square root of. Let's use 12. There are three steps:

   1. Guess
   2. Divide
   3. Average.

      ... and then just keep repeating steps 2 and 3.

First, start by guessing a square root value. It helps if your guess is a good one but it will work even if it is a terrible guess. We will guess that 2 is the square root of 12.

In step two, we divide 12 by our guess of 2 and we get 6.

In step three, we average 6 and 2: (6+2)/2 = 4

Now we repeat step two with the new guess of 4. So 12/4 = 3

Now average 4 and 3: (4+3)/2 = 3.5

Repeat step two: 12/3.5 = 3.43

Average: (3.5 + 3.43)/2 = 3.465

We could keep going forever, getting a better and better approximation but let's stop here to see how we are doing.

    3.465 * 3.465 = 12.006225

That is quite close to 12, so we are doing pretty well.


It might help,When dealing with logical stuff like this, in programming it's better to know how we get an answer and then base a formula on what we got.

**EDIT**
After i reviewed the post a couple of times I guess this would work
Code:

float x,y,w //X is the user number,and Y is the average,W is the outcome of x/y
int ee //ee is are variables in our for loop
do
{
w=x/y
for(ee;ee<=5000;ee++;)
(w+ee)/2=y
}while(y!=x)

_________________
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Mar 16, 2007 7:09 pm    Post subject: Reply with quote

Also, implement a check in your code so you don't divide by 0.
Back to top
View user's profile Send private message
Death4ngel
Grandmaster Cheater Supreme
Reputation: 0

Joined: 23 Sep 2006
Posts: 1226
Location: Singapore

PostPosted: Fri Mar 16, 2007 8:34 pm    Post subject: Reply with quote

#include <cmath>

using namespace std;

void main() {
sqrt(4);
}

//I think. Can't remember the actual one.

_________________
//GOD!!! THOSE STUPID RETARDED SHITHEADS NEVER MAKE IT PAST THIS STEP!!!!!!
//Thats why it's out....
Back to top
View user's profile Send private message MSN Messenger
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Sat Mar 17, 2007 5:47 am    Post subject: Reply with quote

Flyte wrote:
Also, implement a check in your code so you don't divide by 0.


It's awsome when you do. The program crashes.
Back to top
View user's profile Send private message MSN Messenger
lukechin
Grandmaster Cheater
Reputation: 0

Joined: 24 Jun 2006
Posts: 536
Location: in willy wonkas factory

PostPosted: Wed Mar 28, 2007 8:47 pm    Post subject: Reply with quote

Devv wrote:
Yayyyy! Someone learning C++. Well, the math lib has pretty much all the functions you need but I guess you want a challenge.

Try using strings to calculate from since int's are limited. Make your own functions and start at the bottom (add) and work your way up. Wink

Add some cool ascii graphic picture of a calculator for startup. Add some help commands -h for help -a for about -s for syntax etc. I also suggest that you use argv, argc for input. (If you can use them)

[EDIT]Int main is a good start of every program!


you cant do math with strings.... INTs are for math

_________________
hmm back once again....
Back to top
View user's profile Send private message Visit poster's website
Aetherine
Master Cheater
Reputation: 0

Joined: 07 Mar 2007
Posts: 278
Location: The place you'd least expect me.

PostPosted: Thu Mar 29, 2007 7:57 pm    Post subject: Reply with quote

Death4ngel wrote:
#include <cmath>

using namespace std;

void main() {
sqrt(4);
}

//I think. Can't remember the actual one.


void main()?!

NOOOOOOOOOOOOO! Shocked

_________________
ᆲᅨᆰ예ᄈ￞ᆵᆬ○ᆭᆵ'￿ᅨ¦ᅮ¥￰￷￞ᅮ.ᅨ>=$
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
Goto page 1, 2  Next
Page 1 of 2

 
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