Chapter 3: I/O Management

Slides:



Advertisements
Similar presentations
Lecture 2 Introduction to C Programming
Advertisements

Introduction to C Programming
CS1061 C Programming Lecture 16: Formatted I/0 A. O’Riordan, 2004.
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
Display a 12-Month Calendar CS-2301 D-term Programming Assignment #2 12-Month Calendar CS-2301 System Programming C-term 2009 (Slides include materials.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Declarations/Data Types/Statements. Assignments Due – Homework 1 Reading – Chapter 2 – Lab 1 – due Monday.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
Introduction to C Programming
Assignment #2, 12- month Calendar CS-2301, B-Term Programming Assignment #2 12-Month Calendar CS-2301, System Programming for Non-Majors (Slides.
Introduction to C Language
The printf Method The printf method is another way to format output. It is based on the printf function of the C language. System.out.printf(,,,..., );
 2007 Pearson Education, Inc. All rights reserved C Formatted Input/Output.
Ping Zhang 10/08/2010.  You can get data from the user (input) and display information to the user (output).  However, you must include the library.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
Chapter 9 Formatted Input/Output. Objectives In this chapter, you will learn: –To understand input and output streams. –To be able to use all print formatting.
Chapter 3 Processing and Interactive Input. 2 Assignment  The general syntax for an assignment statement is variable = operand; The operand to the right.
Introduction to C Programming Chapter 2 : Data Input, Processing and Output.
C Programming Lecture 5 : Basic standard I/O Lecture notes : courtesy of Ohio Supercomputing Center, science and technolgy support.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
3. FORMATTED INPUT/OUTPUT. The printf Function The first argument in a call of printf is a string, which may contain both ordinary characters and conversion.
Chapter 7 C supports two fundamentally different kinds of numeric types: (a) integer types - whole numbers (1) signed (2) unsigned (b) floating types –
E-1 University of Washington Computer Programming I Lecture 5: Input and Output (I/O) © 2000 UW CSE.
S CCS 200: I NTERACTIVE I NPUT Lect. Napat Amphaiphan.
Operating System Discussion Section. The Basics of C Reference: Lecture note 2 and 3 notes.html.
Department of Electronic & Electrical Engineering IO reading and writing variables scanf printf format strings "%d %c %f"
Department of Electronic & Electrical Engineering Lecture 3 IO reading and writing variables scanf printf format strings "%d %c %f" Expressions operators.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
Formatted I/O ä ä Standard Output ä ä printf() family of functions ä ä Standard Input ä ä scanf() family of functions.
Introduction to Computing Lecture 03: Basic input / output operations Introduction to Computing Lecture 03: Basic input / output operations Assist.Prof.Dr.
C Formatted Input/Output
CSCE 206 Structured Programming in C
Formatted Input and Output
Input and Output: I/O Finish reading chapters 1 and 2 of the text
ECE Application Programming
Formatted Input/Output
Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA
Input/output.
TMF1414 Introduction to Programming
Revision Lecture
Unit-4, Chapter-2 Managing Input and Output Operations
ICS103 Programming in C Lecture 3: Introduction to C (2)
Lecture2.
Formatted Input/Output
Plan of the Day: More on type conversions scanf printf format strings
OUTPUT STATEMENTS GC 201.
Input and Output Lecture 4.
Formatted Input/Output
C Formatted Input / Output Review and Lab Assignments
CSI 121 Structured Programming Language Lecture 7: Input/Output
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Formatted Input/Output
A First Book of ANSI C Fourth Edition
Programming Assignment #1 12-Month Calendar—
Differences between Java and C
Chapter 3: Expressions and Interactivity
EECE.2160 ECE Application Programming
Formatted Input/Output
Conversion Check your class notes and given examples at class.
Formatted Input/Output
Formatted Input/Output
Introduction to C Programming
Introduction to C CSE 2031 Fall /15/2019 8:26 AM.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
EECE.2160 ECE Application Programming
Getting Started in Python
Presentation transcript:

Chapter 3: I/O Management

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.

Why following printf() is wrong printf(“%d %d”, i); printf(“ %d”, i, j); int i; float x; printf(“%f %d\n”,i,x);

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)

Example

Escape Sequence Non printing character having special meaning Start with \ Some common escape sequence are

The scanf() function Takes input from user, Syntax scanf(“string ”, &variable, &variable, ………..) Never FORGET to use & before variable Confusing printf() and scanf() …

Input fraction

Thank you