Variables Arithmetic IO

itx0 n x sm axx1 ae s x sm axx 1 ae

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: can use the following shorthand for changing the values of variables. The shorthand form is shown, then the equivalent form is described in comments. dul a=00 obe .; itx=0 n ; x+ +; / sm a:x=x+1 / ae s ; x-; / sm a:x=x-1 / ae s ; x+ 2 =; / sm a:x=x+2 / ae s ; x- 2 =; / sm a:x=x-2 / ae s ; x* 2 =; / sm a:x=x*2 / ae s ; x/ 2 =; / sm a:x=x/2 / ae s ; x% 2 =; / sm a:x=x%2 / ae s ; a+ 20 = .; / ec / t. / sm a:a=a+20 / ae s .; Boolean operators Variables of type b o have the following special operators: ol bo p=TU; ol RE bo q=FLE ol AS; bo r ol ; r=!; p / &quot;&quot;mas&quot;o&quot;o &quot;poie,s r= FLE / ! en nt r opst&quot; o = AS r=p| q |; / &quot;| mas&quot;r,s r= TU / |&quot; en o&quot; o = RE r=p&amp; q &amp;; / &quot;&amp; mas&quot;n&quot; s r= FLE / &amp;&quot; en ad, o = AS r=q| (p / r= FLE | !) / = AS Note that you cannot use &quot;shorthand&quot; operators with Boolean variables. The following does not do what you expect: r ! p =; Mathy example This example shows use of several mathematical functions and operators. / mt eape / ah xml #nld &lt;otem icue isra&gt; #nld &lt;mt&gt; icue cah uignmsaesd sn aepc t; itmi( n an) { cu &lt; &quot;h rcpoa o 1 i &quot;&lt; 101. &lt; ed; ot &lt; Te eircl f 0 s &lt; ./00 &lt; nl cu &lt; &quot;h sur ro o 1 i &quot;&lt; sr(00 &lt; ed; ot &lt; Te qae ot f 0 s &lt; qt1.) &lt; nl cu &lt; &quot;^1.)=&quot;&lt; ep1.)&lt; ed; ot &lt; e(00 &lt; x(00 &lt; nl cu &lt; &quot;h rcpoa o 1 i &quot;&lt; 101. &lt; ed; ot &lt; Te eircl f 5 s &lt; ./50 &lt; nl cu &lt; &quot;h sur ro o 1 i &quot;&lt; sr(50 &lt; ed; ot &lt; Te qae ot f 5 s &lt; qt1.) &lt; nl cu &lt; &quot;^1.)=&quot;&lt; ep1.)&lt; ed; ot &lt; e(50 &lt; x(50 &lt; nl rtr 0 / ei porm eun ; / xt rga } Here is the example again, but this time with a variable x : #nld &lt;otem icue isra&gt; #nld &lt;mt&gt; icue cah uignmsaesd sn aepc t; itmi( n an) { dul x obe ; x=1.; 00 cu &lt; &quot;h rcpoa o 1 i &quot;&lt; 10x&lt; ed; ot &lt; Te eircl f 0 s &lt; ./ &lt; nl cu &lt; &quot;h sur ro o 1 i &quot;&lt; sr()&lt; ed; ot &lt; Te qae ot f 0 s &lt; qtx &lt; nl cu &lt; &quot;^&quot;&lt; x&lt; &quot; =&quot;&lt; epx &lt; ed; ot &lt; e( &lt; &lt;) &lt; x() &lt; nl x=1.; 50 cu &lt; &quot;h rcpoa o 1 i &quot;&lt; 10x&lt; ed; ot &lt; Te eircl f 5 s &lt; ./ &lt; nl cu &lt; &quot;h sur ro o 1 i &quot;&lt; sr()&lt; ed; ot &lt; Te qae ot f 5 s &lt; qtx &lt; nl cu &lt; &quot;^&quot;&lt; x&lt; &quot; =&quot;&lt; epx &lt; ed; ot &lt; e( &lt; &lt;) &lt; x() &lt; nl rtr 0 / ei porm eun ; / xt rg...
View Full Document

Ask a homework question - tutors are online