Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 3: I/O Management

Similar presentations


Presentation on theme: "Chapter 3: I/O Management"— Presentation transcript:

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


Download ppt "Chapter 3: I/O Management"

Similar presentations


Ads by Google