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
#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 |
How to input string in C++
What is a class in C++?
1 Answers Amazon, TCS, UGC Corporation,
How to generate random numbers in C++ with a range?
Explain what happens when an exception is thrown in C++.
How will you print a list of all unique words from a string which may contain repeated words?
Difference between Call by pointer and by reference.
How to delete array of objects in C++? Proof by C++ code for proper deletion
Write a C++ Program to find Square Root of a number using sqrt() function.
Explain about Searching and sorting algorithms with complexities
Is there a difference between class and struct?
Implement a 2D bit-matrix representing monochrome pixels which will have only OFF/ON values and will take on an average only one bit of memory for each stored bit. How to perform various operations on it?
Define an Abstract class in C++?