1 / 10

DATA INPUT AND OUTPUT

DATA INPUT AND OUTPUT. EC201- FUNDAMENTAL PROGRAMMING. Objective. In this chapter, we explain how to use some of the input/output functions in the standard library,including the functions printf()/puts and scanf()/gets.

gwylan
Télécharger la présentation

DATA INPUT AND OUTPUT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DATA INPUT AND OUTPUT EC201- FUNDAMENTAL PROGRAMMING DTK, JKE, PTSB (V 10.12)

  2. Objective • In this chapter, we explain how to use some of the input/output functions in the standard library,including the functions printf()/puts and scanf()/gets. • General file input/output is important in applications where data reside in files on disks and tapes. We will show how to open files for processing and how to use a pointer to a file. DTK, JKE, PTSB (V 10.12)

  3. Input Output Statements DTK, JKE, PTSB (V 10.12)

  4. printf() function Output: In the program statement above: "%d %s %c %f is the output.\n" is the control string no_bulat, perkataan, huruf, PI is the variable to be printed DTK, JKE, PTSB (V 10.12)

  5. printf Control String Conversion Characters • A table of the control characters used in printf statements is given below: DTK, JKE, PTSB (V 10.12)

  6. Character Escape Sequences • There are several character escape sequences which can be used in place of a character constant or within a string. They are: DTK, JKE, PTSB (V 10.12)

  7. Other output function : puts • The puts() function is a very simple way to send a string to the screen when you have no placeholders to be concerned about. It works very much like the printf() function we saw the “Welcome to C programming" example: Output: DTK, JKE, PTSB (V 10.12)

  8. scanf() function Output: DTK, JKE, PTSB (V 10.12)

  9. scanf Control String Conversion Characters • scanf uses the same conversion characters as printf . • The arguments to scanfmust be pointers (addresses), hence the need for the & character above. The arguments to scanfmust be pointers (addresses), hence the need for the & character above. DTK, JKE, PTSB (V 10.12)

  10. Other input function : gets • gets is a function in the C standard library, declared in the header file stdio.h, that reads a line from the standard input and stores it in a buffer provided by the caller. Use of gets is strongly discouraged. Output: DTK, JKE, PTSB (V 10.12)

More Related