{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 int scanf("format", &var) read formatted int i; double d; scanf("%d", &i); scanf("%lf", &d); 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
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

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online