English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

build C++ program to find numbers of repeat this equation until the value of x=0.001 if : (Xn+1=Xn-0.1Xn) the initial value of X= 1.

2006-11-24 05:30:18 · 3 answers · asked by Sesa 1 in Computers & Internet Programming & Design

3 answers

Let me see if I understand you. You want to find out the first n for which x_n is equal to or less than 0.001?

Here is a sample of code that would do this (though there are easier ways to find the answer):

#include

using namespace std;

int main()
{
int n = 1;
float x_n = 1;
while(x_n > 0.001)
{
n++;
x_n = x_n-0.1*x_n;
}
cout << "When n is " << n << " x_n is " << x_n << endl;
}

2006-11-24 15:18:44 · answer #1 · answered by OS 1 · 0 0

sounds like homework on recursion.

2006-11-24 13:33:30 · answer #2 · answered by D 4 · 0 0

umm, i dont get it. google it, or get a calculator. or ask a teacher.

2006-11-24 13:38:44 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers