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

22 Answers

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 (-581 points)
0 like 0 dislike
Hidden content!
#include<iostream>

using namespace std;

int main()

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

}
answered by (-367 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 (-384 points)
0 like 0 dislike
Hidden content!
#include <iostream>

using namespace std;



class cal

{

private:
** * *** * ** ** ** ** ** ** * a,b,c;

public:
*** ***** * ** * * ** * calculate();
*** * * ** *** * * getValue(int x,int y,int z);

};

void cal::getValue(int x,int y,int z)

{
***** ** * ***** *
*** * * * * * ***
**** * *** * **** * * *

}

int cal::calculate()

{
* * * ** * ** sol;


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

    {
* * * ** * ** * ** * ** ** ** ** * * *** ** * * *
* ** * * * * * * * * *******
*** * * * * ** ** * ** *
** * ***** ** * * *** * ** * * * * * * *
****** *** * **** * * * sol;

}





int main()



{
* *** * ** ** * * * a,b,c,d;
* ** **** * * ** * ** ** t1;
***** **** ** * ** * *** * * *** **** * * ******* ** ** **
***** * * *** * ** * * ****
* * ** ** **** * *** * ** *** *** *
* * ** ***** * ***** **
*** * * ********** ** ** ** *** * ** * * *** ****** *** *** * *** *** ******* is infinite because a-b ****** ****** * ***** * ***
*** * * ** * * ** * *
*** *** *** ******* * * * * * **** * ** ** ** * * *** **** ** **** ** *** * ****** * ***** *
** ** ** * **** **** * * 0;

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

using namespace std;



class cal

{

private:
** * **** * * * * * *** ** a,b,c;

public:
* *** **** * * **** * calculate();
** * * * * *** * * **** * getValue(int x,int y,int z);

};

void cal::getValue(int x,int y,int z)

{
** ** * *** *** * * * *
* ** * ** * ** * * * *
** * * * * **** ** *** ** **

}

int cal::calculate()

{
***** *** * * ** ** sol;


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

    {
** * ******* **** *** ** ** * * *** ** * * *** ***
* * *** *** **** * * * *
*** ****** **** ** ***
* * * * ******* ** *** * ** ** * **
* * * * * ** *** sol;

}





int main()



{
*** ** *** * *** * * * a,b,c,d;
*** * * * * * ** ** ** t1;
* *** ***** * * **** **** * ** * ** ** *** * *
* ** ** * * ** * **** ** *
* * * * **** *** * * ** *
** * ***** *** **
* * * * * ** * * * * ** * * *** ****** ** * ** * * is infinite because a-b ***** * *** * **** * ** * *
* * * * * ** ** * * * * **
* **** ** * * * * *** *** * ******** * ** * *** ** * *** ** * ** ***
*** *** * ** **** * * *** 0;

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

using namespace std;



class cal

{

private:
* ** * * *** * * ***** a,b,c;

public:
* *** ** ** * * * calculate();
** ** ** ** * ** ** getValue(double x,double y,double z);

};

void cal::getValue(double x,double y,double z)

{
**** *** * ** *
* * * * * ***** ** *** * *
** ** ******* * * ** ** * *

}

double cal::calculate()

{
**** *** * ** *** * * * sol;


**** * ** * ******* *
* ****** * * * *** *
** * **** * ** *** * ** **** * * ******** * * * ****
* * ** * **** * *******
** ** ** * * * * * ** * *
* * **** * **** * * * * *** * * * *** ** **
* ** ** ** *** ** * * * * sol;

}





int main()



{
*** * **** **** * * * a,b,c,d;
* * * * ** * * *** * t1;
* ** * ** * **** **** **** * **** * * **
** ** * * * * * * * *
* * * ***** ** * *** **
* ** *** **** * ******* **
*** * * * *** * * ** * * ** ** * ** **** **** * * * * *** ** is infinite because a-b * * **** * ** ** **
*** * ** ** * * ** ** *
* *** **** **** ** * *** * ** *** *** *** * * * * * * * **** ****** ** ** * * *** * *
* **** * ** * ** * * * * ** 0;

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

using namespace std;



class cal

{

private:
*** ** ** * * ******** * ** a,b,c;

public:
*** ****** * * **** *** calculate();
***** * *** **** *** *** * getValue(double x,double y,double z);

};

void cal::getValue(double x,double y,double z)

{
*** * **** ****** * ** **
* *** * ** ** * *
* ** ** * * * * *** *

}

double cal::calculate()

{
* * * **** ** ** * * * * * sol;


* ****** ** *** * * ** ** *****
* * *** *** ** *
** * * ** **** * ** * * *** ** ** ***** * * * * * * *
******* * * * * *** * * ***
********* * ******* ***** ****
* ***** ** ** ** * * * * ** *** * *** ** * * *
** ****** * **** ** ** ** sol;

}





int main()



{
* *** **** * ** ** * ** a,b,c,d;
*** * * * * *** ** * * ** * t1;
*** **** * * * * ** ** *** *** * *** ** *
* * *** * * ** ** *** * *
* * *** **** * *
* * **** * * * * ** * ****
* ** **** * * ** ** ** * * * * * ** * * * * * ** ** ** is infinite because a-b *** *** *** * ** * **
* * * * ** ** ******
* * * * * * ******* * * ** ** ** * ** ** * * ***** * * ** * ** ****** **** *
** * * ** ***** ****** 0;

}
answered by (0 points)
0 like 0 dislike
Hidden content!
** ** * * **

using **** std;



int ***
*** **** int *****
* * **

* * * * *** * cin * ** ** a ** * * b *** * * c ;
* *** * ** * * == 0){
* * ** ***** * ** ** * cout ** ** * ***** ** is ** * ** * a-b ** * ;
* * * * ** *** *

** **** * ** else{
* * ** ** * * * * * * * cout *** ** * * * * *** ** * ** * ;
* ** ** }
**** * * 0;

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

using namespace std;



class cal

{

private:
* ** ** *** * ** a,b,c;

public:
** * * * * * ** ** **** calculate();
*** *** **** * * *** * ** getValue(double x,double y,double z);

};

void cal::getValue(double x,double y,double z)

{
* * * * **** *****
** * * * ***
* * * * * ** * ** * *

}

double cal::calculate()

{
* ** * **** ** ** ** * *** sol;


* * * ** * * * * * ****** **
* * **** ** * **
*** * ** * ** * *** * ** * * * ** * ** * ** *******
*** ** ** * ***** ***** **
****** *** **** ** *
** * ****** ** ** * * ** ** * * * * **** * * **
* ** * * ******** *** ** sol;

}





int main()



{
* * **** *** * * a,b,c,d;
* **** ***** * t1;
* ***** * * ** **** * ** * ** * * * * * ***** * *
* **** *** * ** * * ** *** ** * *
*** * *********** * * * * * * ***
*** ** ** * * ***** * ** ****
** ******* * ****** * * * ** * ** ** ** * * * *** * *** * * is infinite because a-b * *** * * **** **** **
* * ** ****** * *** ** *
* * * *** ** *** * ** ** *** * ** * * ** * **** ** *** * * * * ** * **** * * ** * *** * *** * ***
* ** * * * ** * ** ****** * 0;

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

using namespace std;



int main() {
* ****** ** * *** * a, b, c;


* ** * ** ***** * * ****** * * a * * * ** b * * * ** c;


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


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

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

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
| 6.3k views
0 like 0 dislike
17 answers
[Exercise] Coding (C) - asked Jun 1, 2017 in C++
ID: 24855 - Available when: Unlimited - Due to: Unlimited
| 4.1k views
12,783 questions
183,442 answers
172,219 comments
4,824 users