Code:
#include <iostream.h>;
#include <stdlib.h>;
#include <math.h>;
void main ()
{
float i , A1(1), asmpv1(0.00) , asmpv2(0.00) , asmpv3(0.00) , asmpv4(0.00) , sum(1);
asmpv1 = (1 ^ 2)/4.00);
cout << " For n=1 the asumption value is " << asmpv1 << endl;
cout << " A1 = " << A1 << endl;
cout << " The diff is " << abs(asmpv1-A1) << endl;
for ( i = 2 ; i<=10 ; i++ )
sum += sqrt(sum);
asmpv2 = ((10 ^ 2)/4);
cout << " For n=10 the asumption value is " << asmpv2 << endl;
cout << " A10 = " << sum << endl;
cout << " The diff is " << abs(asmpv2-sum) << endl;
for ( i = 11 ; i<=100 ; i++ )
sum += sqrt(sum);
asmpv3 = ((100 ^ 2)/4);
cout << " For n=100 the asumption value is " << asmpv3 << endl;
cout << " A100 = " << sum << endl;
cout << " The diff is " << abs(asmpv3-sum) << endl;
for ( i = 101 ; i<=1000 ; i++ )
sum += sqrt(sum);
asmpv4 = ((1000 ^ 2)/4);
cout << " For n=1000 the asumption value is " << asmpv4 << endl;
cout << " A1000 = " << sum << endl;
cout << " The diff is " << abs(asmpv4-sum) << endl;
system ("pause");
}
Comment