Formatted I-O scanf

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

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

View Full Document Right Arrow Icon
Formatted I-O scanf read formatted int i; double d; scanf("%d", &i); memory
Background image of page 1

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

View Full DocumentRight Arrow Icon
Idiom ? Example int main() { int i; printf("Enter an integer:"); scanf("%d", &i); printf("%d\n", i);
Background image of page 2
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 );
Background image of page 3

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

View Full DocumentRight Arrow Icon
3: Formatted I/O Float Conversions
Background image of page 4
Background image of page 5
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("%5.3f\n", 123.3456789); printf("%5.3e\n", 123.3456789); 123.346 1.233e+02 double fv; long lv; printf("%lf", fv); scanf("%f", &fv); printf("%ld", lv); scanf("%d", &lv); printf("%d", 3.5); printf("%g", 4); READ MAN PAGES memory...
View Full Document

Page1 / 5

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 Right Arrow Icon
Ask a homework question - tutors are online