 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization.

Slides:



Advertisements
Similar presentations
Introduction to Programming Lecture 39. Copy Constructor.
Advertisements

Chapter 8 Scope, Lifetime and More on Functions. Definitions Scope –The region of program code where it is legal to reference (use) an identifier Three.
1 CS 105 Lecture 3 Constants & Expressions Wed, Jan 26, 2011, 4:15 pm.
Data Types.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)
Data Type. A data type defines a set of values that a variable can store along with a set of operations that can be performed on that variable. Common.
Basic Elements of C++ Chapter 2.
By: Mr. Baha Hanene Chapter 4. LEARNING OUTCOMES This chapter will cover learning outcome no. 2 i.e. Use basic data-types and input / output in C programs.
18-2 Understand “Scope” of an Identifier Know the Storage Classes of variables and functions Related Chapter: ABC 5.10, 5.11.
MAHENDRAN CHAPTER 6. Session Objectives Explain Type of Functions Discuss category of Functions Declaration & Prototypes Explain User Defined Functions.
C Tokens Identifiers Keywords Constants Operators Special symbols.
PASSING VALUE TO A FUNCTION # CALL BY VALUECALL BY VALUE # CALL BY REFERENCECALL BY REFERENCE STORAGE CLASS # AUTOAUTO # EXTERNALEXTERNAL # STATICSTATIC.
Defining and Converting Data Copyright Kip Irvine, 2003 Last Update: 11/4/2003.
Lecture #5 Introduction to C++
18. DECLARATIONS.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
CS212: Object Oriented Analysis and Design Lecture 2: Introduction to C++
CSCI 130 Chapter 3. Variables & Names Variable Declarations: –reserve a storage location in memory –identify the name of the variable –identify the type.
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
CS-1030 Dr. Mark L. Hornick 1 C++ Language Basic control statements and data types.
Chapters 1-5 Review C++ Class. Chapter 1 – the big picture Objects Class Inheritance Reusability Polymorphism and Overloading.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
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 variable is a storage location for some type of value. days 102 taxrate 7.75 int days = 102; double taxrate = 7.75; char grade = ‘A’; boolean done.
Data Types Declarations Expressions Data storage C++ Basics.
Data Structure and c K.S.Prabhu Lecturer All Deaf Educational Technology.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Review 1 List Data Structure List operations List Implementation Array Linked List.
Lecture 7 Pointers & Refrence 1. Background 1.1 Variables and Memory  When you declare a variable, the computer associates the variable name with a particular.
Arithmetic Expressions in C++. CSCE 1062 Outline Data declaration {section 2.3} Arithmetic operators in C++ {section 2.6} Mixed data type arithmetic in.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X 1 Chapter Array Basics.
COMP 102 Programming Fundamentals I Presented by : Timture Choi COMP102 Lab 011.
Chapter 2. Variable and Data type
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
Department of Electronic & Electrical Engineering Statements Blocks{} Semicolons ; Variables Names keywords Scope.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Fundamentals 2.
Chapter # 2 Part 2 Programs And data
Chapter Topics The Basics of a C++ Program Data Types
BASIC ELEMENTS OF A COMPUTER PROGRAM
Data Types, Identifiers, and Expressions
trigraph ??= is for # ??( is for [ ??< is for { ??! is for |
Introduction to C++.
Operator Overloading BCA Sem III K.I.R.A.S.
DATA HANDLING.
Advanced Programming Basics
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Lecture 8.
Basics of ‘C’.
Chapter 2: Java Fundamentals
Local Variables, Global Variables and Variable Scope
Variables & Data types Selection Statements Additional Operators
Seoul National University
Chapter # 2 Part 2 Programs And data
Chapter 2: Java Fundamentals
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Programming Language C Language.
C Programming Lecture-8 Pointers and Memory Management
The C Language: Intro.
Module 2 Variables, Data Types and Arithmetic
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Seoul National University
C Programming Lecture-17 Storage Classes
Variables and Constants
Scope Rules.
Presentation transcript:

 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization  E.g. : const int BONUS = 5000;  There are two ways for creating symbolic constants using keywords: 1. Const 2. enum  steps and rules: 1) Const must be initialized. 2) Const is local to the function where it is declared. 3) By the qualifier extern along with const, it can be made global. 4) If data type is not given it is treated as integer.

 Variable: named storage location whose values can be manipulated during program run  Declaring a variable: as variable can be either of integer type, float or character type so its important to declare a variable having their type for identification using Data-type Declaration Statement as :  Data-type v 1, v V n  E.g. : int a;

 There are two types of variable declaration:  Local declaration: i.e. Inside the main function  E.g.: void main() { int a, b; float x; char name[100]; }  Global decalaration : i.e. Outside the main function  E.g. : #include int a,b; float x; char name[100]; void main { ---- }

 Variable Definition does not provide a first or initial value to a variable  Variable can be initialized in two ways: 1. At the time of variable definition: int a =10; 2. Dynamic initialization: that is during run time using expression at the place of declaration as: float avg; avg = sum/count;