Tiny bit more advanced calculator (Addition Only atm)
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.
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.
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;
}
