Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram. www.ustudy.in.

Slides:



Advertisements
Similar presentations
Lecture 9. Lecture 9: Outline Strings [Kochan, chap. 10] –Character Arrays/ Character Strings –Initializing Character Strings. The null string. –Escape.
Advertisements

Dale Roberts Basic I/O – printf() CSCI 230 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Department of.
Types and Variables. Computer Programming 2 C++ in one page!
1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf 9.4Printing Integers 9.5Printing Floating-Point.
Chapter 9 Formatted Input/Output Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
Data types and variables
 2000 Prentice Hall, Inc. All rights reserved. Chapter 9 - Formatted Input/Output Outline 9.1Introduction 9.2Streams 9.3Formatting Output with printf.
Chapter 2 Data Types, Declarations, and Displays
Chapter 2: Introduction to C++.
C programming Language and Data Structure For DIT Students.
 2007 Pearson Education, Inc. All rights reserved C Formatted Input/Output.
Variable & Constants. A variable is a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines.
Objectives You should be able to describe: Data Types
A First Book of ANSI C Fourth Edition
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved Streams Streams –Sequences of characters organized.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 9 - Formatted Input/Output Outline 9.1Introduction.
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.
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Chapter 9 Formatted Input/Output Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
EPSII 59:006 Spring Introduction In this lecture  Formatted Input/Output scanf and printf  Streams (input and output) gets, puts, getchar, putchar.
 2005 Pearson Education, Inc. All rights reserved Formatted Output.
Input & Output: Console
2440: 211 Interactive Web Programming Expressions & Operators.
C-Language Keywords(C99)
Input, Output, and Processing
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Lecture #5 Introduction to C++
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Knowledge Base C++ #include using std namespace; int main(){} return 0 ; cout
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
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.
CONSTANTS Constants are also known as literals in C. Constants are quantities whose values do not change during program execution. There are two types.
A Simple Java Program //This program prints Welcome to Java! public class Welcome { public static void main(String[] args) { public static void main(String[]
Constants, Variables and Data types in C The C character Set A character denotes any alphabet, digit or special symbol used to represent information.
Topics to be covered  Introduction to C Introduction to C  Characterstics of C Characterstics of C  Characterset Characterset  Keywords Keywords 
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
Ajmer Singh PGT(IP) Programming Fundamentals. Ajmer Singh PGT(IP) Java Character Set Character set is a set of valid characters that a language can recognize.
Operating System Discussion Section. The Basics of C Reference: Lecture note 2 and 3 notes.html.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 2.
Formatted I/O ä ä Standard Output ä ä printf() family of functions ä ä Standard Input ä ä scanf() family of functions.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
28 Formatted Output.
Chapter 9 - Formatted Input/Output
Introduction to ‘c’ language
C Formatted Input/Output
Topics Designing a Program Input, Processing, and Output
Chapter-01 A Sample C++ Program.
Wel come.
TMF1414 Introduction to Programming
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
C++ Basics.
2.1 Parts of a C++ Program.
Escape Sequences Some Java escape sequences: See Roses.java (page 68)
Basics of ‘C’.
C AS A LANGUAGE Interface between computer & human being. ALPHABETS
Chapter 9 - Formatted Input/Output
Introduction to Programming - 3
Chapter 2: Introduction to C++.
Topics Designing a Program Input, Processing, and Output
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Topics Designing a Program Input, Processing, and Output
Presentation transcript:

Constants in C A Presentation On Department of Computer & Information Technology, M.S.P.V.L. Polytechnic College, Pavoorchatram.

Introduction A constant is a quantity whose value does not change during programming execution. There are three types of constants they are Numeric constant Character constant String constant

Numeric constant A numeric constant is a constant made up of digits and some special characters. There are two types of numeric constants. They are Integer or fixed point constant Real or floating point constant

Integer constant Integer constant is a constant made up of digits without decimal point. This can have values from -32,708 to +32,627 Rules An integer constant is formed with digits 0 to 9. The constant can be preceded by + or – sign. No special characters are allowed anywhere in the constant.

Real Constant The numbers with decimal point are called real constant or floating point constant. A real constant is formed with the digits 0..9 and a decimal point. The number can be preceded by + or – The digits before and after the decimal point can be omitted. No white spaces or special characters are allowed. Floating point constants can be represented with f for floating and l for double precision floating point numbers. The real constants can be expressed in two forms a) Fraction form b) Exponential form

a)Fractional Form: The number is written with one decimal point Example: are valid real number in fractional form. b) Exponential form: This is useful for representing very large or very small numbers in magnitude. The general form is Mantissa e or E exponent Example: The number can be written in exponent notation as e2 The number can be written as -3.75e-5

Character Constant There are two types of character constants. They are Direct Escape sequence

Single character constant: A single character constant consists of a single character enclosed within single quotes. The single character constants are stored in memory using their ASCII equivalent. So every character constant has an integer value corresponding to its ASCII value. For example the character 'A' has the equivalent integer ASCII value 65. Example: ‘$’ ‘e’ ‘9’ are character constants Here ‘9’ is not equal to numeric 9.

Escape Sequences The Escape Sequences are special characters for formatting. Character combinations consisting of a backslash (\) followed by a letter or by a combination of digits are called "escape sequences." These special printing characters are used to make the output readable when printing characters to the screen, file, or other device (such as printer).

Character for Bell (Alert) is '\a'. Character for Backspace is '\b'. Character for Horizontal Tab is '\t'. Character for Vertical Tab is '\v'. Character for Newline (Line Feed) is '\n'. Character for Form Feed is '\f'. Character for Carriage Return is '\r'. Character for Quotation Mark is '\"'. Character for Apostrophe is '\''. Character for Question Mark is '\?'. Character for Backslash is '\\'. Character for Null is '\0'.

String Constant A string constant is a sequence of characters enclosed within double quotation marks. This can be formed with digits, alphabets and special characters. Example: “C Program” “!Hello****” are valid string constants