0 like 0 dislike
2.5k views
Show more...
[Exercise] Coding (C) - asked in C++
ID: 24588 - Available when: Unlimited - Due to: Unlimited

edited by | 2.5k views
0 0
Called for Help
0 0
Called for Help

31 Answers

0 like 0 dislike
Hidden content!
#include ****** ** * * **



using namespace std;



class Adder{
***** * *** **
* * **** * * ** * * *
**** *** * * ** **** * * **
** ***** ** ** * * ** * * * *** * ** * a)
*** * ** * **** ****
* * * ** * ** ** ** * ** * * ****** * ** * * * = ** *** + a.sum);
* **** **** * ** * ** * ** * * * ******* *this;
* *** * * *****
*** * * ** * * ** * ** ** * Adder &a)
* ** * * *****
*** ** * * ** ** ** * ****** * ** ** ****** ** * ** == a.sum)
* ** *** * *** ** * ****** * **** * **** ********** * *** ** ** * * 1;
* * * * * ** ** ** **** ** * * **** *** *
*** ** * ** * ** ** * ** *** * * ** * ** * ** * *** * * * * *** * *** 0;
* ** * ** * * * **
* **** ******* * ** * *** *** * * ** * * * * ** ***** os, const Adder &a)
*** **** * *** **
* ** * * ** * ** **** * * * ** * * * ** *** ** ** a.sum;
****** ** *** *** **** *** ********** * **** * * *** * os;
** ** * * * * *** * * **
* * *** *** * ****
* * * * * ** * * ** * * sum;

};


** **

{
** * * ** ** * * = 0;

}


***** a)

{
** ** *** * ***** * *** * = a;

}



int main()

{
* * * * ** * * * x,y;
**** * * ** *** ** * * * * *** ** x * * * y;
* ******* *** * * * * sum1; // sum1 is initialized to 0
* * * * * ***** * * * sum2(x); // sum2 is initialized to x
* ** *** * * ** * * * * sum3(y); // sum1 is initialized to y
* **** * * *** * * ** * ****** is " * * *** * sum1 ** **** '\n'; // prints ** * is 0"
*** *** **** * * ** * ** ** * * ** * ** is " *** * ***** sum2 ** ** * * '\n'; // prints * ** * is x"
** ** ** **** **** * * **** * *** * ** ** is " * * ** * sum3 * ** * '\n'; // prints * ** is y"
* * * * ********* * += x; //adds x to sum1; now sum1 is x
*** ** ** * **** ** += -3; // adds -3 to sum2; now sum2 is x-3
* * * * * **** **** * += 2; //adds 2 to sum3; now sum3 is y+2
*** ** ******* * *** * *** (sum1 == sum2)
*** ** **** *** *** *** ** * * ****** *** * *** * ** ** * * *** and sum2 are the ** *****
** * * * *** *
* * ******* * * ** * * * ** **** * * * * ** * * and sum2 are not the * *****
** * * * *** *** ** * (sum1 == sum3)
* * * *** * * ** ***** ** *** * * *** * ** ** ** *** **** * **** and sum3 are the *** ****
**** *** * *** * ** ** ***
**** ** * * * *** * ** * **** ** ** * ***** * ** and sum3 are not the * * * * **
* *** * * * **** * 0;

}
answered by (5.2k points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.126.116
©2016-2025

Related questions

0 like 0 dislike
30 answers
[Exercise] Coding (C) - asked May 18, 2017 in C++
ID: 24769 - Available when: Unlimited - Due to: Unlimited
| 2.5k views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 1.7k views
0 like 0 dislike
15 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24854 - Available when: Unlimited - Due to: Unlimited
| 1.7k views
12,783 questions
183,442 answers
172,219 comments
4,824 users