Here is my first own programme,i was trying to calculate error of finding roots for a second degree equation.I used float type for variables to see all result but i cant see results after some numbers.anyone can help this poor beginner with this?
Code:#include <iostream> #include <cmath> using namespace std; int main() { int i; float p=1,X11,X12,E,Er; for (i=0; i<10; i++) { p=p*10; X11= -(p/2)- sqrt ((pow(p,2)/4)-1); X12= 1 /((-(p/2)+sqrt ((pow(p,2)/4)-1))); E= X11-X12; Er= E/X11; cout << "X^2-"<<p<<"x+1=0"<<endl; cout <<"X11="<<X11<<'\t'; cout <<"X12="<<X12<<endl; cout <<"E="<<E<<'\t'<<"Er="<<Er<<endl; } std::cout <<"Press [Enter] to continue" <<std::endl; std::cin.get(); return 0; }



LinkBack URL
About LinkBacks



