What else I should add into my calculator!?

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
#include <iostream>

using namespace std;

int main()
{
int int1,int2,product,sum,division,large,small,subtract;
double average;

cout << "Enter the 1st integer\n";
cin >> int1;
cout << "Enter the 2nd integer\n";
cin >> int2;

sum = int1 + int2;
cout << "Sum is: " << sum << endl;

product = int1 * int2;
cout << "Product is: " << product << endl;

subtract = int1 - int2;
cout << "Subraction is: " << subtract << endl;

average = sum / 2;
cout << "Average is: " << average << endl;


if ( int1 < int2 )
    cout << int1 << " is less than " << int2 << endl;

if ( int1 > int2 )
    cout << int1 << " is greater than " << int2 << endl;

    return 0;
}


Don't give the codes. I just need suggestions!

EDIT: Damn it! I forgot to do the division lol.
Last edited on
Powers, roots, and factorials might be nice.

Also, on line 24, you are doing integer division, so if the integers you input add to say, 5, you will get an average of 2, not 2.5 like you would expect.
@firedraco: Yeah..... I need to work on that at line 24.
logarithms.
@dancks: what?

Anyways, how do I do the powers? Can I do it in this way?
1
2
3
4
5
6
7
8
power1 = int1 * int1;
    cout << "[1st Integer]Power to the second is: " << power1 << endl;
power2 = int1 * int1 * int1;
    cout << "[1st Integer]Power the the third is: " << power2 << endl;
power3 = int2 * int2;
    cout << "[2nd Integer]Power to the second is: " << power3 << endl;
power4 = int2 * int2 * int2;
    cout << "[2nd Integer]Power to the third is: " << power4 << endl;
logarithm? 100 log 10 = 2
calculate n where 10^n = number entered.
DetectiveRawr:

use:
#include <cmath>

Then:
1
2
power = pow(base, exp);
    cout << base << " to the power of " << exp << " is: " << power << endl;
@Stewbond: Thanks mate!
Topic archived. No new replies allowed.