Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void Sums(int, int&, int&, int&);
- int main(){
- int N, o1 = 0, o2 = 0, o3 = 0;
- char again = 'y';
- while (again == 'y' || again == 'Y'){
- cout << "Please input a number and i calculate 3 sums: ";
- cin >> N;
- Sums(N, o1, o2, o3);
- cout << "1 to N is : " << o1
- << "\nN+23 to N+200 is: " << o2
- << "\n2N to 5n is: " << o3 << endl << endl;
- cout << " Do you want to continue (y|Y)?: ";
- cin >> again;
- }
- }
- void Sums(int in, int& _1_N, int& n23_100, int& _2n_5n){
- _1_N = 0, n23_100 = 0, _2n_5n = 0; //reinitialize
- int n23 = (in + 23), n100 = (in + 100), N2 = (in*2), N5= (in*5);
- for (int ctr = 1; ctr <= in; ctr++)
- _1_N += ctr;
- for (int ctr2 = n23; ctr2 <= n100; ctr2++)
- n23_100 += ctr2;
- for (int ctr3 = N2; ctr3 <= N5; ctr3++)
- _2n_5n += ctr3;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement