Basic Input - Output. Output functions  printf() – is a library function that displays information on-screen. The statement can display a simple text.

Slides:



Advertisements
Similar presentations
Character Arrays (Single-Dimensional Arrays) A char data type is needed to hold a single character. To store a string we have to use a single-dimensional.
Advertisements

CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
Programming In C++ Spring Semester 2013 Lecture 2 Programming In C++, Lecture 2.
11-2 Identify the parts of the “main” function, which include Preprocessor Directives main function header main function body which includes Declaration.
Lecture 2 Introduction to C Programming
Introduction to C Programming
Outline 2.1 Introduction 2.2 Basics of C Programs
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
CS1061 C Programming Lecture 16: Formatted I/0 A. O’Riordan, 2004.
Software Development Method. Assignments Due – Homework 0, Warmup Reading – Chapter 2 –
Introduction to C Programming CE Lecture 2 Basics of C programming.
1 Key Concepts:  Data types in C.  What is a variable?  Variable Declaration  Variable Initialization  Printf()  Scanf()  Working with numbers in.
PHYS 2020 Basic C An introduction to writing simple but useful programs in C In these lectures I will take you through the basics of C, but you will need.
Basic Input/Output and Variables Ethan Cerami New York
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
C - Input & Output When we are saying Input that means to feed some data into program. This can be given in the form of file or from command line. C programming.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
C Programming Lecture 3. The Three Stages of Compiling a Program b The preprocessor is invoked The source code is modified b The compiler itself is invoked.
1 IPC144 Session 11 The C Programming Language. 2 Objectives To format a #define statement correctly To use a #define statement in a C program To construct.
Input & Output: Console
C-Language Keywords(C99)
Lecture 2 Introduction to Computer Programming CUIT A.M. Gamundani Presentation Layout Data types.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
CHAPTER 2 PART #3 INPUT - OUTPUT 1 st semester King Saud University College of Applied studies and Community Service Csc
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
Week 1 Algorithmization and Programming Languages.
CHAPTER 7 DATA INPUT OUTPUT Prepared by: Lec. Ghader R. Kurdi.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
CSCI 171 Presentation 2. Program Components main() #include Variable Definition Function Prototype Program Statements Function Call Function Definition.
CSCI 130 Chapter 3. Variables & Names Variable Declarations: –reserve a storage location in memory –identify the name of the variable –identify the type.
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
PHYS 2020 Basic C An introduction to writing simple but useful programs in C In these lectures I will take you through the basics of C, but you will need.
DATA TYPE AND DISPLAY Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
CSC141 Introduction to Computer Programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture - 6.
Chapter-4 Managing input and Output operation.  Reading, processing and writing of data are three essential functions of a computer program.  Most programs.
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
Program Development Cycle 1.Edit program 2.Compile program - translates it from C to machine language 3. Run/execute your program. 4. If not satisfied,
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
CSCI 130 Basic Input and Output Chapter 9. The printf ( ) function Printf(“\nThe value of x is %d”, x); Displayed to screen (assume x = 12): –The value.
C Building Block Chapter 2. Variables A variable is a space in the computer’s memory set aside for a certain kind of data and given a name for easy reference.
Sudeshna Sarkar, IIT Kharagpur 1 Programming and Data Structure Sudeshna Sarkar Lecture 3.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
Formatted I/O ä ä Standard Output ä ä printf() family of functions ä ä Standard Input ä ä scanf() family of functions.
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.
Chapter 2 - Introduction to C Programming
TMF1414 Introduction to Programming
Revision Lecture
Chapter 2 Overview of C.
Chapter 2 - Introduction to C Programming
By: Syed Shahrukh Haider
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
INPUT & OUTPUT scanf & printf.
Chapter 2 - Introduction to C Programming
Variables T.Najah Al_Subaie Kingdom of Saudi Arabia
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
Introduction to C Programming
Introduction to C Programming
Presentation transcript:

Basic Input - Output

Output functions  printf() – is a library function that displays information on-screen. The statement can display a simple text message or a message and the value of one or more program variables  gotoxy() – positions the cursor on a specific location on the screen  clrscr() – clears the screen and place the cursor at the upper left hand portion of the screen

Input functions  scanf() – reads data from the keyboard according to a specified format and assigns the input data to one or more program variables. For numeric variables, the address can be passed by the address of operator, the ampersand (&) that is placed at the beginning of the variable name.  getch() / getche() – gets a character from the keyboard. It waits until a key is pressed and then returns the inputted character to the calling function. Unlike the scanf() function, getch/e() does not wait for the carriage return key to be pressed. The difference between the getch() and getche() is that the latter echoes the typed character to the screen.

Escape Sequences  \ rcarriage return \\\\nnewline \\\\tmove to the next tab \\\\abeep the speaker \\\\bbackspace ’prints single quote \\\\”prints double quote \\\\\prints backslash character \\\\xddprints character whish is in hexadecimal form

Format Specifier  % ccharacter %%%%sstring %%%%dinteger %%%%ffloat %%%%eexponential %%%%xhexadecimal %%%%ooctal %%%%ldlong integer %%%%lflong float / double precision

Declaration of Variables A variable is a named data storage location in your computer’s memory. Variables in C can contain letters, digits and the underscore character ( _ ). It should be remembered that C language is case sensitive; two similar words in different cases generate two different variables. A variable declaration tells the compiler the name and type of a variable and optionally initializes the variable to a specific value. When a variable is declared, the compiler sets aside a storage space for the variable.

Variable Type Keyword Bytes Required Range Characterchar to 127 Integerint to Long integer iong int to Floatfloat4 1.2E-38 to 3.4E38 Double precision double8 2.2E-308 to 1.8E308