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 


Your own C++ basic Calculator
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
SmarterDen3
Grandmaster Cheater
Reputation: 0

Joined: 07 Feb 2007
Posts: 976
Location: [color=red]behind you[/color]

PostPosted: Wed Feb 27, 2008 8:49 pm    Post subject: Your own C++ basic Calculator Reply with quote

Code:
// i/o example

#include <iostream>
using namespace std;

int main ()
{
  int i; // i- short for integer/int
  cout << "Please enter an integer value: ";
  cin >> i;
  cin.get();
  cout << "The value you entered Smartz one. " << i;
  cout << " and The final answer is..??? " << i%3 << ".\n"; //% can be changed to +,-,/, %,* modulo, the 3 stands for the number to +,-,/,*,%

  cin.get();
  return 0;
}



Its a basic one. Very Happy

_________________


Last edited by SmarterDen3 on Wed Feb 27, 2008 8:51 pm; edited 1 time in total
Back to top
View user's profile Send private message
Madman
I post too much
Reputation: 1

Joined: 04 May 2006
Posts: 3978

PostPosted: Wed Feb 27, 2008 8:50 pm    Post subject: Reply with quote

There is a programming section.

People are posting too general of topics in the Computer Talk section.

_________________
Back to top
View user's profile Send private message
SF
I'm a spammer
Reputation: 119

Joined: 19 Mar 2007
Posts: 6028

PostPosted: Wed Feb 27, 2008 8:52 pm    Post subject: Reply with quote

Moved.
_________________
Back to top
View user's profile Send private message
SmarterDen3
Grandmaster Cheater
Reputation: 0

Joined: 07 Feb 2007
Posts: 976
Location: [color=red]behind you[/color]

PostPosted: Wed Feb 27, 2008 8:52 pm    Post subject: Reply with quote

Sorry.. Very Happy Didnt see the programming section

/Slaps*

_________________
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Feb 27, 2008 9:13 pm    Post subject: Reply with quote

Rolling Eyes at the very least let the user pick the option.
Back to top
View user's profile Send private message
Mynameisnick
Cheater
Reputation: 0

Joined: 26 Feb 2008
Posts: 27
Location: On top of the world trade center 9/11

PostPosted: Sat Mar 01, 2008 12:17 am    Post subject: Reply with quote

(this works with windows computers and im not sure about the rest)you know you have a built in calculator if you click start then go to all programs then accessories and click calculator,there you go and the next time just go to the start menu
_________________
Back to top
View user's profile Send private message
MrNeef
Cheater
Reputation: 0

Joined: 26 Feb 2008
Posts: 44

PostPosted: Sat Mar 01, 2008 7:34 pm    Post subject: Reply with quote

Code:
#include <iostream>
#include <string> // We will be using a string, so this will come in handy!

using namespace std;

int main ()
{

   while ( 1 == 1 ) { // Infinite loop

   float f; // First value
   float s; // Second value
   string op; // Operator string

   cout << "First value: "; // Says the user to enter their first value
   cin >> f; // Gets first value from the user
   cout << "Operator ( -, +, / or * ): "; // Says the user to enter their operator
   cin >> op; // Gets operator from the user
   cout << "Second value: "; // Says the user to enter their second value
   cin >> s; // Gets second value from the user

   if ( op == "-" ) { // If users operator choise is - then..
cout << f << op << s << " = " << f-s << endl; // Calculate first value minus second value
   }

   else if ( op == "+" ) { // If users operator choise is + then..
cout << f << op << s << " = " << f+s << endl; // Calculate first value plus second value
   }

   else if ( op == "/" ) { // If users operator choise is / then..
cout << f << op << s << " = " << f/s << endl; // Calculate first value devided by second value
   }

   else if ( op == "*" ) { // If users operator choise is * then..
cout << f << op << s << " = " << f*s << endl; // Calculate first value times second value
   }

cout << "\n\n"; // Adds 2 new lines
   }

  system("pause");
  return 0;
}


I made this quickly, so I didn't add any comments. This will let the user choose the operator Very Happy

EDIT //
Added comments, didn't test it yet, should work though!

_________________
Stop leeching, start learning.

Current Projects :
MrNeef's DLL injector + MrNeef's basic DLL [ 75% ]
Back to top
View user's profile Send private message
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Sat Mar 01, 2008 9:12 pm    Post subject: Reply with quote

Try making it evaluate mathematical sentences (like "5 * (4 + 7) - 6 * (9 + 2) ).

Then maybe move on from there to things like linear equations.

A simple four-function isn't really anything to be proud of (no offense).

Edit:

Whoops, I was looking at the post above me. Though, the OP isn't really much to be proud of either. ._.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
Back to top
View user's profile Send private message
MrNeef
Cheater
Reputation: 0

Joined: 26 Feb 2008
Posts: 44

PostPosted: Sat Mar 01, 2008 9:20 pm    Post subject: Reply with quote

samuri25404 wrote:
Try making it evaluate mathematical sentences (like "5 * (4 + 7) - 6 * (9 + 2) ).

Then maybe move on from there to things like linear equations.

A simple four-function isn't really anything to be proud of (no offense).

Edit:

Whoops, I was looking at the post above me. Though, the OP isn't really much to be proud of either. ._.


I'm not proud of it. I made it up quickly... you could edit it to your wishes. Also I'm still learning C++, sorry for not being '1337'.

_________________
Stop leeching, start learning.

Current Projects :
MrNeef's DLL injector + MrNeef's basic DLL [ 75% ]
Back to top
View user's profile Send private message
Br1tn3y
How do I cheat?
Reputation: 0

Joined: 01 Mar 2008
Posts: 9

PostPosted: Sat Mar 01, 2008 9:21 pm    Post subject: Reply with quote

What happens when you divide by 0?
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Mar 01, 2008 9:31 pm    Post subject: Reply with quote

Likely a crash.
Back to top
View user's profile Send private message
systat
Advanced Cheater
Reputation: 0

Joined: 15 Feb 2008
Posts: 54

PostPosted: Sun Mar 02, 2008 6:28 am    Post subject: Reply with quote

my own...

Code:
#include <iostream>
#include <cmath>
using namespace std;

int main(int argc, char *argv[]) {
   if(argc<4) {
      cerr << "Not enough parameters!" << endl;
      return 1;
   }
   double operand1=atof(argv[1]);
   char operatorl=*argv[2];
   double operand2=atof(argv[3]);
   switch(operatorl) {
      case('+'):
         cout << (operand1 + operand2) << endl;
         break;
      case ('-'):
         cout << (operand1 - operand2) << endl;
         break;
      case ('*'):
         cout << (operand1 * operand2) << endl;
         break;
      case ('/'):
         cout << (operand1 / operand2) << endl;
         break;
      default:
         cerr << "Unknown operator " << operatorl << endl;
         return 1;
   }
   return 0;
}

_________________
uuuuuuuuuuuuu
Back to top
View user's profile Send private message
AtheistCrusader
Grandmaster Cheater
Reputation: 6

Joined: 23 Sep 2006
Posts: 681

PostPosted: Sun Mar 02, 2008 6:42 am    Post subject: Reply with quote

Very basic
but still good for beginning

oftopic:

Back to top
View user's profile Send private message
Santtu K
Newbie cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 17

PostPosted: Sun Mar 02, 2008 12:37 pm    Post subject: Reply with quote

hahha I beat yours mines 5 functional :3
wrote this in like few mins, nothing special

Code:
#include <iostream>
// 5 functional calculator... sky

using namespace std;

int main()
{
  int f: // function
  int z; // 1st number
  int y; // 2nd number
  int a; // answer
   cout <<"Please enter 1st number: \n"; // asks user to type 1st number
    cin >> z:
     cin.ignore();
   cout <<"Please enter 2nd number: \n"; // asks user to type 2nd number
    cin >> y;
     cin.ignore();
   cout <<"Please Enter the function you want to use (+,-,*,/,%): \n";
    cin >> f; //  above asks user to type function to use
     cin.ignore();

  if ( f = "+" ) { // adding
  (a = z + y);
   cout <<"Answer: "<< a << \n";
    cin.get(); 
}
 else if ( f = "-" ){ // subtraction
  (a = z - y);
   cout <<"Answer: "<< a << \n";
    cin.get();
}

 else if ( f = "*" ){ // multiplication
  (a = z * y);
   cout <<"Answer: "<< a << \n";
    cin.get();
}

 else if ( f = "/" ){ // division
  (a = z / y);
   cout <<"Answer: "<< a << \n";
    cin.get();
}

 else ( f = "%" ){ // percentage calculation
  (a = 100 / z * y);
   cout <<"Answer: "<< a << %\n";
    cin.get();
}

}


next step to add cos, sin and tan

_________________
nowadaysidoc++andasm
Back to top
View user's profile Send private message
SmarterDen3
Grandmaster Cheater
Reputation: 0

Joined: 07 Feb 2007
Posts: 976
Location: [color=red]behind you[/color]

PostPosted: Wed Oct 15, 2008 6:19 pm    Post subject: Reply with quote

yea i remember this a long time ago, from this point i gained a lot of things.
_________________
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