0 like 0 dislike
2.3k views

We need to build a program that performs this algorithm:

Step 1: Read the values a,b,c,.

Step 2: Inside the try block check the condition.

            a. if(a-b!=0) then calculate the value d=c/(a-b); and display.

            b. otherwise throw the exception.

Step 3: Catch the exception and display the appropriate message.

Step 4: Stop the program.

Example input:

5 5 8

Output:

Answer is infinite because a-b is:0

Example input 2:

5 7 8

Output:

Result is:-4

 Example input 3:

3 6 8

Output:

Result is:-2
[Exercise] Coding (C) - asked in C++
ID: 24895 - Available when: Unlimited - Due to: Unlimited

edited by | 2.3k views
0 0
Notice: You may have 100% output, but your code matters!

22 Answers

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



using namespace std;



int main()

{
** * ** * ********** a, b, c, d;
* * * * * ** * **
** ** *** * * **
* *** * **** * * * **** **** ** * * * * ** >> a >> b * *** * * c;


** * ** * * * * **** ** * **** *** * ** ** (a-b == 0)
* * * ** *** * ** ** * ** * * **** * ** * ** ******* * * * a-b;


** ** * * * ** *** * ***** ** **** * * ** ** = c/(a-b);
*** ** ** * *** * * * ** * *** * ** **** * * * * * ** * ** * *** is:" ******* d;
*** ** ** * * * *
* * ** * * * * ** ** e)
*** * *** ** * * * * ** **
* ** ***** ** ** * * * ** * * * ** * * ***** ***** * ****** * * ** ** ** * is infinite because a-b is:" << e;
**** * ** ** * ***


***** * ** * 0;

}
answered by (5.2k points)
0 like 0 dislike
Hidden content!
#include * * * * *



using namespace std;



int main()

{
** * * ***** * * *** * * a, b, c, d;
* ** * ** * * **
* * * ** * *
** * ** ***** * *** ** *** ** **** * * **** * >> a >> b ** * * c;


*** * **** *** **** * * ** *** (a-b == 0)
** * *** * ** * * ** ** *** ** ** * * ** ** ** * ** * ** * * a-b;


* * ** * ** * * * * **** ** * * ** * = c/(a-b);
** * * * * * *** ** ***** * ***** * * * **** * * ** * is:" ** * **** d;
* *** * ******* * ** **** *
***** * * *** * * * * ** * e)
* * * * ** *** * *
** * ******* ** * *** ** **** ****** **** ** ** *** * ** ** * ** ** * is infinite because a-b is:" << e;
** **** *** * * *** *


** * * * ** *** ** 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.69.7.199
©2016-2025

Related questions

0 like 0 dislike
27 answers
[Exercise] Coding (C++) - asked Jun 8, 2017 in C++
ID: 24896 - Available when: Unlimited - Due to: Unlimited
| 3.2k views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 2k views
12,783 questions
183,442 answers
172,219 comments
4,824 users