JustPaste
HomeCategoriesAboutDonateContactTerms of UsePrivacy Policy
JustPaste

Free online notepad — write and share instantly

Navigate

  • Home
  • Timeline
  • Categories

Info

  • About
  • Donate
  • Contact

Legal

  • Terms of Use
  • Privacy Policy

© 2026 JustPaste.app. All rights reserved.

Made with ♥ by JustPaste

Untitled Page | JustPaste.app
5 months ago66 views
#include<iostream>
#include<cmath>
#define EPS 0.00001

using namespace std;

float g(float x){
	return 5+.5*sin(x);
}

int main(){
	float x0, x1;
	int n=1;
	cout<<"Enter an inital point x0\n";
	cin>>x0;
	
	x1=g(x0);
	while(fabs((x1-x0)/x1)>EPS){
		n++;
		x0=x1;
		x1=g(x0);
		if(g(x1)==x1) break;
	}
	
	cout<<"The approximation root of the given function is " << x1 << " with " << n <<" number of interation";
		
}

⚠️Content was pasted as plain text and auto-formatted as a code block. Use the Code Block button in the editor for proper formatting.

← Back to timeline