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

Hello!! I would like to know where to stop a loop that is used to solve a set of linear equations. Generally, it is stopped when x1-x0<0.001 or sumthin like that. Any c++ statement to help??

2006-11-07 04:16:15 · 1 answers · asked by Girish 1 in Science & Mathematics Engineering

Some problems I am having are:
- Some of the values do not converge.
- Some of the values are negative.
How do I check for these in an IF statement??
Note: x2-x1 gives the value that is checked for convergence and the maximum iterations allowed is 15.

2006-11-08 15:53:15 · update #1

1 answers

if you are using a "while" or "do while" loop

while ((x1 - x0) > 0.001)
{
//your code here
}

or you can do this

do
{
//your code here
}
while ((x1 - x0) > 0.001);

2006-11-08 01:33:45 · answer #1 · answered by justme 7 · 0 0

fedest.com, questions and answers