See below
/PWM
On Mon, 17 Mar 2003, Vincent Ogwuagwu wrote:
> Please wrote a program that does a large number of
> calculations within a loop for each value of a real
> number that is used for the loop. However, when I
> compiled and ran the program, it only recognized the
> first value of the loop, while in the actual sense it
> is supposed to calculate for three values of the real
> number. Could someone let me know how to design the
> loop to recognize the other values. The loop is as
> shown below:
>
>
> for(i=3D1;i<=3D5;i++);
Your loop both starts and stops at this single line, because you end it
with the semicolon...
>
> {
>
> =93
> =93
> theta2 =3D theta2 + 30.0;
> if(theta2 >=3D 90.0);
What use is an if statement without any following action?
Besides, never, never test for equality when working with floating point
numbers. Round-off errors might bite real hard.
if (theta2 > 91.0) do_something();
or
if (theta2 > (90.0 + eps)) do_something();
> }
>
> The output (Print) statement is also within the loop.
>
> Thank you.
>
> Vincent.
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Web Hosting - establish your business online
> http://webhosting.yahoo.com
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by:Crypto Challenge is now open!
> Get cracking and register here for some mind boggling fun and
> the chance of winning an Apple iPod:
> http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|