Answer to Question #292411 in C++ for Mariko

Question #292411

Write a program to calculate the value of f(x) if u r given that f(x) =x+1, x<1



3x^2-x, x>1



10-x, x=1

1
Expert's answer
2022-01-31T08:55:03-0500
#include<iostream>

using namespace std;

int main()
{
	double x;
	char choice;
	do
	{
		cout<<"\nDo you want to calculate f(x) [Y/N]: ";
		cin>>choice;
		if(choice=='n'||choice=='N')break;
		cout<<"Please, enter a value of x: ";
		cin>>x;
		if(x<1)
			cout<<"f(x) = "<<x+1;
		else if(x>1)
			cout<<"f(x) = "<<3*x*x-x;
		else if(x==1)
			cout<<"f(x) = "<<10-x;
	}while(true);
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog