Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Alexander Shmakov (Alex)
- * CIS 22A Fall 2014
- * Laboratory Assignment H
- * Problem H1
- *
- * This program takes two inputs
- * and finds the sum of the inputs.
- * It does this twice.
- **/
- #include <iostream>
- using namespace std;
- int sum(int a, int b);
- void takeInput(int& a, int& b);
- int main()
- {
- int x, y;
- takeInput(x, y);
- cout << x << " + " << y << " = " << sum(x,y) << endl;
- takeInput(x, y);
- cout << x << " + " << y << " = " << sum(x, y) << endl;
- return 0;
- }
- //************************************
- // Method: sum
- // Returns: int
- // int a:
- // int b:
- // Description:
- //************************************
- int sum(int a, int b)
- {
- return a + b;
- }
- //************************************
- // Method: takeInput
- // Returns: void
- // int & a: first input
- // int & b: second input
- // Description: Prompts the user to input two integers and saves them
- //************************************
- void takeInput(int& a, int& b)
- {
- cout << "Please enter the first number: ";
- cin >> a;
- cout << "Please enter the second number: ";
- cin >> b;
- }
- /* Execution Results:
- Please enter the first number: 3
- Please enter the second number: 4
- 3 + 4 = 7
- Please enter the first number: 5
- Please enter the second number: 49
- 5 + 49 = 54
- **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement