Variables Arithmetic IO

# we often need to show a specific number of digits

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: gt;; cu &lt; &quot;ne a0frFLE ayhn es frTU:&quot; ot &lt; Etr o AS, ntig le o RE ; cn&gt; p i &gt;; The function c nonly collects input up to the first space or newline. i c ncan i be used to obtain multiple inputs. It knows when to delimit (i.e. start looking for the next input) when it reaches a space or newline (or tab). Here's the same example as above, but using just one c n i: dul a obe ; itx n; bo p ol ; cu &lt; &quot;ne adcml itgr adboenvle &quot; ot &lt; Etr eia, nee, n ola au: ; cn&gt; a&gt; x&gt; p i&gt; &gt; &gt;; We can get strings in the usual way: srn wr; tig od cu &lt; &quot;ne awr:&quot; ot &lt; Etr od ; cn&gt; wr; i &gt; od However, using that technique, you cannot get strings that have spaces. To get strings that have spaces in them, we have to use this method: srn s tig ; / gtawoeln o tx fo teue adsv it tevral s /e hl ie f et rm h sr n ae no h aibe gtiecn s; eln(i, ) That method gets a whole line of text, which could have spaces. Printing with precision When printing &quot;floating-point values&quot; (such as floats, doubles, etc.) we often need to show a specific number of digits after the decimal point. This is known as the &quot;precision&quot; of the number. The actual precision of the value will not change; we will only change the printed precision. The following will show three digits after the decimal point: cu.rcso() otpeiin3; cu.efis:ie,is:lafed; otst(o:fxd o:fotil) Here is a complete example: #nld &lt;otem icue isra&gt; uignmsaesd sn aepc t; itmi( n an) { dul x obe ; cu &lt;...
View Full Document

Ask a homework question - tutors are online