| 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]
|
Posted: Wed Feb 27, 2008 8:49 pm Post subject: Your own C++ basic Calculator |
|
|
| 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.  _________________
Last edited by SmarterDen3 on Wed Feb 27, 2008 8:51 pm; edited 1 time in total |
|
| Back to top |
|
 |
Madman I post too much
Reputation: 1
Joined: 04 May 2006 Posts: 3978
|
Posted: Wed Feb 27, 2008 8:50 pm Post subject: |
|
|
There is a programming section.
People are posting too general of topics in the Computer Talk section. _________________
|
|
| Back to top |
|
 |
SF I'm a spammer
Reputation: 119
Joined: 19 Mar 2007 Posts: 6028
|
Posted: Wed Feb 27, 2008 8:52 pm Post subject: |
|
|
Moved. _________________
|
|
| Back to top |
|
 |
SmarterDen3 Grandmaster Cheater
Reputation: 0
Joined: 07 Feb 2007 Posts: 976 Location: [color=red]behind you[/color]
|
Posted: Wed Feb 27, 2008 8:52 pm Post subject: |
|
|
Sorry.. Didnt see the programming section
/Slaps* _________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Feb 27, 2008 9:13 pm Post subject: |
|
|
at the very least let the user pick the option. |
|
| Back to top |
|
 |
Mynameisnick Cheater
Reputation: 0
Joined: 26 Feb 2008 Posts: 27 Location: On top of the world trade center 9/11
|
Posted: Sat Mar 01, 2008 12:17 am Post subject: |
|
|
(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 |
|
 |
MrNeef Cheater
Reputation: 0
Joined: 26 Feb 2008 Posts: 44
|
|
| Back to top |
|
 |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sat Mar 01, 2008 9:12 pm Post subject: |
|
|
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. ._. _________________
|
|
| Back to top |
|
 |
MrNeef Cheater
Reputation: 0
Joined: 26 Feb 2008 Posts: 44
|
Posted: Sat Mar 01, 2008 9:20 pm Post subject: |
|
|
| 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 |
|
 |
Br1tn3y How do I cheat?
Reputation: 0
Joined: 01 Mar 2008 Posts: 9
|
Posted: Sat Mar 01, 2008 9:21 pm Post subject: |
|
|
| What happens when you divide by 0? |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Sat Mar 01, 2008 9:31 pm Post subject: |
|
|
| Likely a crash. |
|
| Back to top |
|
 |
systat Advanced Cheater
Reputation: 0
Joined: 15 Feb 2008 Posts: 54
|
Posted: Sun Mar 02, 2008 6:28 am Post subject: |
|
|
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 |
|
 |
AtheistCrusader Grandmaster Cheater
Reputation: 6
Joined: 23 Sep 2006 Posts: 681
|
Posted: Sun Mar 02, 2008 6:42 am Post subject: |
|
|
Very basic
but still good for beginning
oftopic:
 |
|
| Back to top |
|
 |
Santtu K Newbie cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 17
|
Posted: Sun Mar 02, 2008 12:37 pm Post subject: |
|
|
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 |
|
 |
SmarterDen3 Grandmaster Cheater
Reputation: 0
Joined: 07 Feb 2007 Posts: 976 Location: [color=red]behind you[/color]
|
Posted: Wed Oct 15, 2008 6:19 pm Post subject: |
|
|
yea i remember this a long time ago, from this point i gained a lot of things. _________________
|
|
| Back to top |
|
 |
|