0 like 0 dislike
3.8k 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 | 3.8k views
0 0
Notice: You may have 100% output, but your code matters!

22 Answers

0 like 0 dislike
Hidden content!
#include <iostream>



using namespace std;



int main()

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




** * * * *** *** ***** * * ** * 0;

}
answered by (-298 points)
0 like 0 dislike
Hidden content!
#include <iostream>



using namespace std;



int main()

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




*** * * * * *** * * 0;

}
answered by (-215 points)
0 like 0 dislike
Hidden content!
#include <iostream>



using namespace std;



int main()

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




* **** ** *** * *** *** ** 0;

}
answered by (237 points)
0 like 0 dislike
Hidden content!
#include <iostream>



using namespace std;



int main()

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




*** * * * * *** * 0;

}
answered by (126 points)
0 like 0 dislike
Hidden content!
#include<iostream>

using namespace std;

int main(){
** * ** *** * * ***** a,b,c,d;
***** * * ** * **** * ** *** ** **** ** ** **** *
* **** ** * ** * ** *** ***** **
* * *** * *** **** ****** * * * *** **** ***
* ** * * ** *** * ** ** ** **** * * ** * * * * ** ** * is:"<<d;
* ** *** ** * * *** * ** **
** * *** * * ***** * **
* ** ***** * ** * *** ** ** * * *** * ** *** ********** **** is infinite because a-b is:0";
* * * * * ** **** * ** 0;

}
answered by (-249 points)
0 like 0 dislike
Hidden content!
#include * **** ****

using * * std;



int tryA(int a, int b, int c){
* *** * * * ** * * * *** return 0;
* ** **** * ** * ** * return *

}



int ** *
** ** *** * * ** * ** N[3], i;
* * * **** ** * * * **** ** i++) cin * *** * N[i];
* ** ** * * * ** * *** N[1], ** *
* **** ** ** * * ** *** * ** *** * * ** * * * * ** * * * **** * * is infinite because a-b ** *
* ** ** * *** * ***** **
**** ** ** ** * * ** ***** ** * * * * **** * ** * * * * *** *** * * ** ** **** **** *** * * N[1], * ****

}
answered by (-368 points)
0 like 0 dislike
Hidden content!
#include <iostream>

using namespace std;



int main(void)

{
* ***** **** * ** a,b,c;


* ** ** * ** * * ****** * *** **** *** * * ** *


* * ** * ** ** ***** *** ** ***
* *** * * ** ** * **
**** ** ** * *** *** *** ** ** * ** *** * ** ** *** ** ** *** ** is infinite because a-b is:"<<a-b;
* * * * ** *** ***
**** * ** ** *** ***** ** *
** * * * * * **** * *
****** * * * * ** * * ** **** ** ** * * ** * * * **** ** ** *** *** *
* ** **** * * * * ***** **

}
answered by (-324 points)
0 like 0 dislike
Hidden content!
#include * **** * *

using std::cin;

using std::cout;



int main()

{
** ***** ***** * ** * num1,num2;
***** **** * *** * * * num3;
*** * * ** ** *** ** * caculation;
** * ** * * * * **
***** * ** ** *** ** *****


* ** * * ** * *** * ** ** ** * * * * **** num1 * * ******* num2 ** * *** ** * num3;
** **** * * ** * ** * * * * * * ** - num2)==0)
* ******** * * *** ** *** ** *** * **** **** * ** * * * ** *** ** ** * (num1-num2);


* ** **** * * * * * ****** *** * * * * * = * ** ** * * ****** * - num2);


********* ** ** *** * *** ** * *** * ** * ****** * * * is:" * * ** * * caculation;


* * * * ***** **** ** *


* * * *** * * ** *** *** (int e)
**** * **** *** ****
* * **** ** * **** * * * * ** ** * **** << "Answer is infinite because a-b is:" * * * * e;
* * * ** * * ***
** * *** ****** * * * * 0;

}
answered by (-412 points)
0 like 0 dislike
Hidden content!
#include <iostream>



using namespace std;



int main()

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




* * ** ** * * **** * 0;

}
answered by (-189 points)
0 like 0 dislike
Hidden content!
#include<iostream>

using namespace std;

int main()

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

}
answered by (-367 points)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.69.130.92
©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
| 4.8k views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 3.1k views
12,783 questions
183,442 answers
172,219 comments
4,824 users