Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- using namespace std;
- int value[256];
- char operation;
- char continueno;
- bool firstpass = false;
- int total;
- int caculation(int number1, int number2)
- {
- if(operation == '+')
- {
- return number1 + number2;
- }
- if(operation == '-')
- {
- return number1 - number2;
- }
- if(operation == '*')
- {
- return number1 * number2;
- }
- if(operation == '/')
- {
- return number1 / number2;
- }
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- for (;;)
- {
- if(firstpass = false)
- {
- cout << "Welcome to the C++ console tutorial with arrays\nThis is a custom tutorial to see how much I know in pointless console C++"
- "\nEnjoy!\nPlease enter in your first value\n";
- }
- else{
- cout << "Please enter in your first value";
- }
- cin >> value[1];
- cout << "\nGood, now please enter in your second value";
- cin >> value[2];
- cout << "Good, now enter in a operation sign please.";
- cin >> operation;
- total = caculation(value[1],value[2]);
- cout << "Your total is " << total << endl << "Would you like to try again?";
- cin >> continueno;
- if (continueno == 'y' || continueno == 'Y')
- {
- continue;
- firstpass = true;
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement