Write a program to read the values a, b and c and display x, where
x=a/b–c.
Test the program for the following values:
(a) a = 250, b = 85, c = 25
(b) a = 300, b = 70, c = 70



Write a program to read the values a, b and c and display x, where x=a/b–c. Test the program..

Answer / hr

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
float a,b,c,x;
cout<<" Enter the value of a,b, &c :"<<endl;
cin>>a>>b>>c;
if((b-c)!=0)
{
x=a/(b-c);
cout<<" x=a/(b-c) = "<<x<<endl;
}
else
{
cout<<" x= infinity "<<endl;
}
return 0;
}
OUTPUT:
Enter the value of a,b,&c:300 70 70
X=infinity

Is This Answer Correct ?    2 Yes 5 No

Post New Answer

More C++ Interview Questions

If class D is derived from a base class B

1 Answers  


What is a COPY CONSTRUCTOR and when is it called?

1 Answers   IBS,


Write a program to input an integer from the keyboard and display on the screen “WELL DONE” that many times.

1 Answers  


What is name mangling/name decoration?

1 Answers   Amazon,


write a program To generate the Fibonacci Series.

1 Answers   Accenture,


What is the difference between creating an object, using 'new' and using 'malloc'?

3 Answers   HFG, Siemens,


Tell us the size of a float variable.

1 Answers   Accenture,


Can we call a virtual function from a constructor?

2 Answers  


What is a virtual function in C++?

1 Answers   C DAC,


What is a virtual base class?

6 Answers   Fidelity, Siemens,


How do you write a function that can reverse a linked-list in C++?

1 Answers   IBS,


Identify the errors in the following program. #include <iostream> using namespace std; void main() { int i=5; while(i) { switch(i) { default: case 4: case 5: break; case 1: continue; case 2: case 3: break; } i-; } }

1 Answers  


Categories