Data in a C++ Program Numeric data and character data

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
1 C++ Syntax and Semantics The Development Process.
C++ Basics Variables, Identifiers, Assignments, Input/Output.
Dale/Weems/Headington
1 9/10/07CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
Structure of a C program
1 9/8/08CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
CS150 Introduction to Computer Science 1
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
Variables and constants Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences.
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.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
Variables and Data Types
Input & Output: Console
C Tokens Identifiers Keywords Constants Operators Special symbols.
Lecture 2 Introduction to Computer Programming CUIT A.M. Gamundani Presentation Layout Data types.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
IXA 1234: C++ PROGRAMMING CHAPTER 2: PROGRAM STRUCTURE.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
1 C++ Syntax and Semantics, and the Program Development Process.
CISC105 – General Computer Science Class 9 – 07/03/2006.
Primitive Variables.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
CSCI 130 Chapter 3. Variables & Names Variable Declarations: –reserve a storage location in memory –identify the name of the variable –identify the type.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
Primitive Variables.
Data Types Declarations Expressions Data storage C++ Basics.
Chapter 4 Literals, Variables and Constants. #Page2 4.1 Literals Any numeric literal starting with 0x specifies that the following is a hexadecimal value.
Today’s Lecture  Literal  Constant  Precedence rules  More assignment rules  Program Style.
1.2 Primitive Data Types and Variables
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
Lecture 5 Computer programming -1-. Input \ Output statement 1- Input (cin) : Use to input data from keyboard. Example : cin >> age; 2- Output (cout):
MIT AITI Lecture 2 The of Java In the following lectures you will learn the basic structures that make up the Java programming language: »Variables.
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization.
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
Variables and Types. Primitive Built-in Type Type Meaning Minimum Size bool boolean NA char character 8 bits wchar_t wide character 16 bits char16_t Unicode.
Basic Concepts:- Invalid use of Address Operator &75 &(‘a’) &(a+b)
Integer VariablestMyn1 Integer Variables It must be possible to store data items in a program, and this facility is provided by variables. A variable is.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Chapter Topics The Basics of a C++ Program Data Types
Variables Mr. Crone.
Data Types, Variables & Arithmetic
Variable Declarations
ITEC113 Algorithms and Programming Techniques
Basic Elements of C++.
EPSII 59:006 Spring 2004.
Variables ,Data Types and Constants
DATA HANDLING.
Basic Elements of C++ Chapter 2.
Advanced Programming Basics
Wrapper Classes The java.lang package contains wrapper classes that correspond to each primitive type: Primitive Type Wrapper Class byte Byte short Short.
Chapter 2 Variables.
Default Arguments.
Variables in C Declaring , Naming, and Using Variables.
Programming Language C Language.
POINTER CONCEPT 4/15/2019.
Variables in C Topics Naming Variables Declaring Variables
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
Variables and Constants
POINTER CONCEPT 8/3/2019.
Presentation transcript:

Data in a C++ Program Numeric data and character data Use variables to hold a data in memory Each variable has a name Each variable has a type Each variable holds a value that you stored in it Valid variable names: salary, aug99_sales, I, AgeLimit, Amount Never give a variable name the same name as a C++ command Give your variables meaningful names

signed char (same as char) int unsigned int signed int (same as int) Variable Types char unsigned char signed char (same as char) int unsigned int signed int (same as int) short int unsigned short int long int long (same as long int) signed long int (same as long) unsigned long int float double long double Define Variables main() { int age, weight; char initial; float salary; // Rest of program follows }

Putting Values in Variables main() { int age, dependents; float salary; age = 32; salary = 25000.00; dependents = 2; // Rest of program follows } { char first, middle, last; first = ‘G’; middle = ‘M’; last = ‘P’;

You can use a constant variable anywhere you can use a variable, but Constant Variables You can use a constant variable anywhere you can use a variable, but you cannot change constant variables after their initializations at definitions const int days_of_week = 7; You must put an initial value into the constant variable C++ assumes a constant without type to be of int type main() { const float salary = 234.54; const int age = 16; // Rest of program follows }