Topics discussed in this section:

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Computer Science: A Structured Programming Approach Using C Converting File Type A rather common but somewhat trivial problem is to convert a text.
Figure 1.1 Basic components of a simple computer system © 2003 Brooks/Cole Publishing / Thomson Learning™
Review for midterm exam Dilshad M. Shahid Spring NYU.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 6P. 1Winter Quarter I/O in C Lecture 6.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Introduction to C Programming
Integrated Science Unit 2, Chapter 4.
CMSC 104, Version 8/061L18Functions1.ppt Functions, Part 1 of 4 Topics Using Predefined Functions Programmer-Defined Functions Using Input Parameters Function.
Computer Science: A Structured Programming Approach Using C Masks In many programs, bits are used as binary flags: 0 is off, and 1 is on. To set.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
General Programming Introduction to Computing Science and Programming I.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
Computer Science: A Structured Programming Approach Using C A Programming Example— Morse Code Morse code, patented by Samuel F. B. Morse in 1837,
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To be able to list and describe the six expression categories ❏ To understand.
How to start Visual Studio 2008 or 2010 (command-line program)
Computer Science: A Structured Programming Approach Using C1 2-7 Input/Output Although our programs have implicitly shown how to print messages, we have.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the structure, union, and enumerated types ❏ To use the type definition.
A Level Computing#BristolMet Session ObjectivesU2#S12 MUST describe the terms modal and pretty printing in term of input and output facilities. SHOULD.
Topics discussed in this section:
Computer Science: A Structured Programming Approach Using C1 2-7 Input/Output Although our programs have implicitly shown how to print messages, we have.
Chapter 3 w Variables, constants, and calculations DIM statements - declaration temporary memory locations identifier, data type, scope data types - values.
1 Objectives ❏ To understand the differences between text and binary files ❏ To write programs that read, write, and/or append binary files ❏ To be able.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
Exercise 1 #include int main() { printf(“Hello C Programming!\n”); return 0; } 1.Run your Visual Studio 2008 or Create a new “project” and add.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the concept and use of pointers ❏ To be able to declare, define,
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the relationship between arrays and pointers ❏ To understand the.
Computer Science: A Structured Programming Approach Using C1 5-5 Incremental Development Part II In Chapter 4, we introduced the concept of incremental.
Computer Science: A Structured Programming Approach Using C1 5-5 Incremental Development Part II In Chapter 4, we introduced the concept of incremental.
CSCI N305: C Programming Copyright ©2006  Department of Computer & Information Science File Handling in C.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the basic properties and characteristics of external files ❏ To.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the differences between text and binary files ❏ To write programs.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Introduction to Computing Science and Programming I
Chapter 3 Program Design
INTRODUCTION TO PROBLEM SOLVING
What Actions Do We Have Part 1
Chapter 7 Text Input/Output Objectives
Topics discussed in this section:
Chapter 7 Text Input/Output Objectives
Chapter 12 Enumerated, Structure, and Union Types Objectives
Introduction to the C Language
1-1 Logic and Syntax A computer program is a solution to a problem.
Chapter 7 Text Input/Output Objectives
Selection—Making Decisions
FIGURE 9-5 Integer Constants and Variables
Chapter 9 Pointers Objectives
Introduction to the C Language
Binary Files.
Introduction to the C Language
Structure of a C Program
I/O in C Lecture 6 Winter Quarter Engineering H192 Winter 2005
Topics discussed in this section:
Topics discussed in this section:
Topics discussed in this section:
Topics discussed in this section:
An Introduction to Programming with C++ Fifth Edition
Exam # 1 INFORMATION Scheduled for Thursday 7/20
Introduction to C Programming
Topics discussed in this section:
Presentation transcript:

Topics discussed in this section: 2-7 Input/Output Although our programs have implicitly shown how to print messages, we have not formally discussed how we use C facilities to input and output data. We devote two chapters, Chapter 7 and 13, to fully explain the C input/output facilities and how to use them. In this section, we describe simple input and output formatting. Topics discussed in this section: Streams Formatting Input/Output Computer Science: A Structured Programming Approach Using C

for a text stream; a monitor is a destination Note A terminal keyboard and monitor can be associated only with a text stream. A keyboard is a source for a text stream; a monitor is a destination for a text stream. Computer Science: A Structured Programming Approach Using C

FIGURE 2-15 Stream Physical Devices Computer Science: A Structured Programming Approach Using C

FIGURE 2-16 Output Formatting Concept Computer Science: A Structured Programming Approach Using C

FIGURE 2-17 Output Stream Formatting Example Computer Science: A Structured Programming Approach Using C

FIGURE 2-18 Conversion Specification Computer Science: A Structured Programming Approach Using C

Format Codes for Output Table 2-10 Format Codes for Output Computer Science: A Structured Programming Approach Using C

Flag Formatting Options Table 2-11 Flag Formatting Options Computer Science: A Structured Programming Approach Using C

FIGURE 2-19 Formatting Text from an Input Stream Computer Science: A Structured Programming Approach Using C

FIGURE 2-20 Input Stream Formatting Example Computer Science: A Structured Programming Approach Using C

FIGURE 2-21 Conversion Specification Computer Science: A Structured Programming Approach Using C

scanf requires variable addresses in the address list. Note scanf requires variable addresses in the address list. Computer Science: A Structured Programming Approach Using C

Table 2-12 scanf Rules Computer Science: A Structured Programming Approach Using C

2-8 Programming Examples In this section, we show some programming example to emphasize the ideas and concepts we have discussed about input/output. Computer Science: A Structured Programming Approach Using C

A Program That Prints “Nothing!” Computer Science: A Structured Programming Approach Using C

Demonstrate Printing Boolean Constants PROGRAM 2-5 Demonstrate Printing Boolean Constants Computer Science: A Structured Programming Approach Using C

Demonstrate Printing Boolean Constants (continued) PROGRAM 2-5 Demonstrate Printing Boolean Constants (continued) Computer Science: A Structured Programming Approach Using C

Print Value of Selected Characters PROGRAM 2-6 Print Value of Selected Characters Computer Science: A Structured Programming Approach Using C

Print Value of Selected Characters (continued) PROGRAM 2-6 Print Value of Selected Characters (continued) Computer Science: A Structured Programming Approach Using C

Print Value of Selected Characters (continued) PROGRAM 2-6 Print Value of Selected Characters (continued) Computer Science: A Structured Programming Approach Using C

Print Value of Selected Characters (continued) PROGRAM 2-6 Print Value of Selected Characters (continued) Computer Science: A Structured Programming Approach Using C

Calculate a Circle’s Area and Circumference PROGRAM 2-7 Calculate a Circle’s Area and Circumference Computer Science: A Structured Programming Approach Using C

Calculate a Circle’s Area and Circumference (continued) PROGRAM 2-7 Calculate a Circle’s Area and Circumference (continued) Computer Science: A Structured Programming Approach Using C

FIGURE 2-22 Output Specifications for Inventory Report Computer Science: A Structured Programming Approach Using C

A Sample Inventory Report PROGRAM 2-8 A Sample Inventory Report Computer Science: A Structured Programming Approach Using C

A Sample Inventory Report (continued) PROGRAM 2-8 A Sample Inventory Report (continued) Computer Science: A Structured Programming Approach Using C

FIGURE 2-23 Complex Number Attributes Computer Science: A Structured Programming Approach Using C

Print Complex Number Attributes PROGRAM 2-9 Print Complex Number Attributes Computer Science: A Structured Programming Approach Using C

Print Complex Number Attributes (continued) PROGRAM 2-9 Print Complex Number Attributes (continued) Computer Science: A Structured Programming Approach Using C

Complex Number Arithmetic PROGRAM 2-10 Complex Number Arithmetic Computer Science: A Structured Programming Approach Using C

Complex Number Arithmetic (continued) PROGRAM 2-10 Complex Number Arithmetic (continued) Computer Science: A Structured Programming Approach Using C

Complex Number Arithmetic (continued) PROGRAM 2-10 Complex Number Arithmetic (continued) Computer Science: A Structured Programming Approach Using C