Formatted I-O scanf

# Formatted I-O scanf - To print floating point values, the...

This preview shows pages 1–5. Sign up to view the full content.

Formatted I-O scanf read formatted int i; double d; scanf("%d", &i); memory

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Idiom ? Example int main() { int i; printf("Enter an integer:"); scanf("%d", &i); printf("%d\n", i);
3: Formatted I/O . Integer Conversions To print and scan integers, the following conversions are used: d signed decimal ld long decimal (scan only) hd short decimal (scan only) u unsigned decimal o unsigned octal x, X unsigned hexadecimal printf("%d %o %x" , 17, 18 , 19 );

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
3: Formatted I/O Float Conversions
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: To print floating point values, the following conversions are used (the default precision is 6): f [-] ddd.ddd e [-] d.ddddde{sign}dd E [-] d.dddddE{sign}dd g shorter of f and e G shorter of f and E printf(&quot;%5.3f\n&quot;, 123.3456789); printf(&quot;%5.3e\n&quot;, 123.3456789); 123.346 1.233e+02 double fv; long lv; printf(&quot;%lf&quot;, fv); scanf(&quot;%f&quot;, &amp;fv); printf(&quot;%ld&quot;, lv); scanf(&quot;%d&quot;, &amp;lv); printf(&quot;%d&quot;, 3.5); printf(&quot;%g&quot;, 4); READ MAN PAGES memory...
View Full Document

## Formatted I-O scanf - To print floating point values, the...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online