### Labolatory Work Problem(Calculation with use of conditional loop statements))

Greedings!Guys, i have problem with undestanding, where is my mistake on my project. I have done this labolatory task by using method of recurrent factor and when i wanted to pass this program to teacher, i have different values on the S. My value on S is 0,3932 but teacher have 0,41 value.

Who can check my program by formula????????(task and other is attached)

Image of Program --> http://ib2.keep4u.ru/b/2013/01/06/64/6454b5a600e927ec5f2548f2db93be8b.png

Method of solution--> http://user-0.imgfiles.ru/1dq7ewhenv.html
My formula of labwork --> http://user-0.imgfiles.ru/xzq7e0hoo6.html
Code from program -->
//-----------------------------------------
//Table 2.3 - Individual Task , 3 var
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include <math.h>
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
double EPS=StrToFloat(Edit1->Text),x=StrToFloat(Edit2->Text);
int k=1;double a=x;
double S=a;
do
{double r=-x/(k+1.);
a*=r;S+=a;k++;}
while(fabs(a)>EPS);
Memo1->Lines->Add("for x= "+FormatFloat("0.0",x)+" S="+FormatFloat("0.0000",S)+" while k="+FormatFloat("0.0",k));
}
//---------------------------------------------------------------------------

//-----------------------------------------

Source of code, include the project,exe, text of program --> http://rghost.ru/42764166
Last edited on
Topic archived. No new replies allowed.