Dedication of Duty
Important! Every function should have a singular task to perform and no more.
Examples if (x >= 0) root = square_root(x); do { cout<<"enter nonnegative number: "<<endl; cin>>num; } while (num < 0); root = square_root(num); if ( f(x) < 0 ) exit (1); root = square_root(f(x));
Examples if (x >= 0) root = square_root(x); do { cout<<"enter nonnegative number: "<<endl; cin>>num; } while (num < 0); root = square_root(num); if ( f(x) < 0 ) exit (1); root = square_root(f(x));
Examples if (x >= 0) root = square_root(x); do { cout<<"enter nonnegative number: "<<endl; cin>>num; } while (num < 0); root = square_root(num); if ( f(x) < 0 ) exit (1); root = square_root(f(x));
End of Session