Download presentation
Presentation is loading. Please wait.
1
Chapter 3: I/O Management
2
printf() and scanf() function
printf() and scanf() function are used as basic I/O function. printf syntax: printf(string, expression1, expression2, ……) No limit on number of value can be that can be printed Format string may contain ordinary character and conversion specification begin with % Conversion specifier specifies compiler to convert into specific format. Though compiler doesn’t check the conversion specification number should match.
3
Why following printf() is wrong
printf(“%d %d”, i); printf(“ %d”, i, j); int i; float x; printf(“%f %d\n”,i,x);
4
Conversion Specifier d deimal e floating point is exponential
f Display floating point number c character s string %.1f display float value with one digit decimal %4d display with space in front (Right justification) %-4d display with space in back (Left Justification)
5
Example
6
Escape Sequence Non printing character having special meaning
Start with \ Some common escape sequence are
7
The scanf() function Takes input from user, Syntax
scanf(“string ”, &variable, &variable, ………..) Never FORGET to use & before variable Confusing printf() and scanf() …
8
Input fraction
9
Thank you
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.