-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfactor.cpp
More file actions
56 lines (48 loc) · 1.19 KB
/
factor.cpp
File metadata and controls
56 lines (48 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* =====================================================================================
*
* Filename: factor.cpp
*
* Description: returning multiple values
*
* Version: 1.0
* Created: 03/01/13 21:48:07
* Revision: none
* Compiler: gcc
*
* Author: Robert Halliday (rh), rob_halliday_1@hotmail.com
* Company: rphhpr
*
* =====================================================================================
*/
#include <iostream>
enum ERR_CODE { SUCCESS, ERROR };
ERR_CODE Factor(int, int*, int*);
int main()
{
int number, squared, cubed;
ERR_CODE result;
std::cout << "Enter a number (0 - 20): ";
std::cin >> number;
result = Factor(number, &squared, &cubed);
if (result == SUCCESS)
{
std::cout << "number: " << number << "\n";
std::cout << "square: " << squared << "\n";
std::cout << "cubed: " << cubed << "\n";
}
else
std::cout << "Error encountered!!\n";
return 0;
}
ERR_CODE Factor(int n, int *pSquared, int *pCubed)
{
if ( n > 20 )
return ERROR;
else
{
*pSquared = n*n;
*pCubed = n*n*n;
return SUCCESS;
}
}