No offense, but why would someone even want to steal this.
This should, in theory, allow you to add any amount of numbers together, until, of course, you reach the max value that a unsigned long integer can hold, because then, it will freeze there.
I wrote this from scratch at school, so don't even try to claim that any of this code is yours.
You can do whatever you want with the source, it doesn't matter to me.
If you have any suggestions, tell me. I'll be adding other operations later, since they won't take to long.Code:///////////////////////////////////////// //// Eddie's Ownage Calculator //// ///////////////////////////////////////// #include "stdafx.h" #include <iostream> #include <string> using namespace std; void test() { cout << "How many numbers?" << endl; int num; unsigned long int answer = 0; int nums; cin >> nums; cout << endl << "What operation would you like to use?" << endl; char choice; cin >> choice; switch (choice) { case '+': for(int i = 0; i <= nums; i++) { if(i == 1) { cout << "First Number? \n"; cin >> num; answer = num + answer; } else if(i >= 2) { cout << "Next Number? \n"; cin >> num; answer = num + answer; } } break; case '-': break; case '*': break; case '/': break; } cout << "The answer is: " << answer << endl; } int main() { test(); system("pause"); return 0; }
No offense, but why would someone even want to steal this.
There are five possible operations for any army. If you can fight, fight; if you cannot fight, defend; if you cannot defend, flee; if you cannot flee, surrender; if you cannot surrender, die." - Sima Yi
B1ackAnge1 (11-16-2009)
I think you can even make your value range longer with "unsigned long long". Never tried it before. It can hold at least 64 bits so it might only work on a 64 bit OS.
Goals In Life:
[X] Become an Advanced Member
[X]Release a tut on mpgh
[0]Post 300 posts
[X]Make a working hack
[X] Learn c++
The only reason I would hand program a calculator is if I was trying to calculate extremely precise or extroadinarily large values. That's when it gets interesting, because a double is essentially the largest value you can calculate on a 32 bit machine, so you have to find otherways around it to make calculate these numbers... so that they don't overflow.
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
[YOUTUBE]<object width="560" height="340"><param name="movie" value="https://www.youtube.com/v/MVchQI1cKwM&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/MVchQI1cKwM&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object>[/YOUTUBE]
4LL 0F TH1S C4LCULATORZ R B3L00NG 2 M3H!!1
Good job I guess
Ah we-a blaze the fyah, make it bun dem!
Yeh it is good practice. Practicing the little things like this will help you to get a good grasps on the concepts. I tried something similar once... I tried to make a chemical formula calculator, but that was before I realized I didn't know shit about chemistry and dropped the course... =/
"Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."- Dwight D. Eisenhower
Hell_Demon (11-17-2009)