1 Chapter 2: Data Types & Operations Part 1 ICS101: Computer Programming Al-Hashim, Amin G.

Slides:



Advertisements
Similar presentations
L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
Advertisements

1 ICS 101 – LAB 2 Arithmetic Operations I Putu Danu Raharja kfupm.edu.sa Information & Computer Science Department CCSE - King Fahd University.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
Data types and variables
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
Javascript II Expressions and Data Types. 2 JavaScript Review programs executed by the web browser programs embedded in a web page using the script element.
Chapter 2 Data Types, Declarations, and Displays
Chapter 2: Introduction to C++.
Chapter 2: Basic Elements of C++
FORTRAN PROGRAMMING BASICS MET 50. Programming Basics The basic layout of all programs is as follows (p.33) PROGRAM name = heading (i.e., title) Specifications.
1 Chapter 2: Data Types & Operations Part 3 ICS101: Computer Programming Al-Hashim, Amin G.
Basic Elements of C++ Chapter 2.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects Seventh.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Binary Codes Computers and other digital systems "work" with binary numbers. I/P & O/P is usually done using decimal numbers, alphabetics, special symbols.
1 © 2000 John Urrutia. All rights reserved. Qbasic Constructing Qbasic Programs.
Five Tips to Success. Work hard Try more exercises and more practice.
CS1 Lesson 2 Introduction to C++ CS1 Lesson 2 -- John Cole1.
1 CSC103: Introduction to Computer and Programming Lecture No 6.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 2: Basic Elements of C++
Lecture #5 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)
Introduction to C++ Basic Elements of C++. C++ Programming: From Problem Analysis to Program Design, Fourth Edition2 The Basics of a C++ Program Function:
Arithmetic Expressions
These notes were originally developed for CpSc 210 (C version) by Dr. Mike Westall in the Department of Computer Science at Clemson.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
What is C? C is a programming language. It was developed in 1972 USA. It was designed and written by a man named dennis ritchie. C is the base for all.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects Sixth.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 8 Arrays.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 2: Basic Elements of C++
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 2: Basic Elements of C++
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 2: Basic Elements of C++
CPS120: Introduction to Computer Science Variables and Constants.
صياغة البرنامج Coding the Program. خرائط التدفق Flowchart ويطلق عليها أيضاً خرائط سير العمليات وهي مجموعة من الرموز المتعارف عليها تستخدم لتوضيح الخطوات.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
 Constants A constant is a fixed value of a data type that cannot be changed Integer Constants Whole numbers → Do not have decimal points Examples: 83.
Lecture 5 Computer programming -1-. Input \ Output statement 1- Input (cin) : Use to input data from keyboard. Example : cin >> age; 2- Output (cout):
CHAPTER 2:BASIC FORTRAN Data Types INTEGER REAL COMPLEX CHARACTER LOGICAL.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Midterm Review Tami Meredith. Primitive Data Types byte, short, int, long Values without a decimal point,..., -1, 0, 1, 2,... float, double Values with.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 2: Basic Elements of C++
 Data Type is a basic classification which identifies different types of data.  Data Types helps in: › Determining the possible values of a variable.
Expressions and Data Types Professor Robin Burke.
1 Scalar and composite data Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 2: Basic Elements of C++
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 2: Basic Elements of C++
Constants, Data Types and Variables
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Expressions and Assignment Statements
Chapter 2: Basic Elements of C++
Chapter 2: Introduction to C++
ITEC113 Algorithms and Programming Techniques
Variables and Primative Types
Chapter 2.
C++ Data Types Data Type
Chapter 2: Introduction to C++.
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
An Introduction to Programming with C++ Fifth Edition
Primitive Types and Expressions
Unit 3: Variables in Java
Repetition (While Loop) LAB 9
DATA TYPES AND OPERATIONS
Basic Programming Lab C.
OUTPUT DESIGN PRINT K, expression list K FORMAT (specification list)
Presentation transcript:

1 Chapter 2: Data Types & Operations Part 1 ICS101: Computer Programming Al-Hashim, Amin G.

2 Outline  Data Types  Constants  Variables

3 Data Types  Data: form of recording  4 basic types of data in FORTRAN:  Integer  Real  Character  Logical

4 Constants  Fixed value  Types:  Integer constants  Real constants  Character constants  Logical constants

5 Integer Constants  Numbers without a decimal point  E.g.:  101 00   1429

6 Real Constants  Numbers with a decimal point  E.g.:  3.4     Representations in FORTRAN:  Ordinarily  Scientific Notation xEy (0.1≤ x <1.0) …

7 Character Constants  Any set of characters between single quotes  E.g.:  ‘FORTRAN is an interesting PL’  ‘I’’am very interesting with ICS101’

8 Logical Constants  2 logical constants in FORTRAN: .TRUE. represents true .FALSE. represents false

9 Variables  Occupies a place at the computer memory  Must have a name to be referenced  Its value can be changed

10 Cont.  Rules of Naming Variables:  Starts with an alphabetic character  May contain digits  Should not contain special characters  Length should not exceed 6 characters  Must not contain blanks  Which of the following are legal variable names? (1) FIVE (2) 5IVE (3) F!VE (4) F I V E (5) FIVE55555 (6) F5

11 Cont.  Types of Variables :  Integer variables  Real variables  Character variables  Logical variables

12 Integer Variables  Hold only integer values  Definition:  Explicit … using the INTEGER statement INETGER X, Y, Z, FIVE  Implicit … variable name starts with I, J, K, L, M, or N ISUM, JAR, KILO  MUST be before any executable statement

13 Real Variables  Hold only real values  Definition:  Explicit … using the REAL statement REAL TAX, FEE, Z, FIVE  Implicit … variable name doesn’t start with I, J, K, L, M, or N SLOPE, WEIGHT, F6  MUST be before any executable statement

14 Character Variables  Hold only character values  Definition:  Explicit ONLY… using the CHARACTER statement CHARACTER NAME*6, COL*10, MAJOR CHARACTER*6 NAME, COL*10, MAJOR  MUST be before any executable statement

15 Logical Variables  Hold only logical values (.TRUE. |.FALSE.)  Definition:  Explicit ONLY… using the LOGICAL statement LOGICAL FLAG, TEST, X, CONT  MUST be before any executable statement

16 Exercise  Find the errors in the following FORTRAN code * FullOfErrors.for C By: Al-Hashim INTEGER OFFICE#, HOURS, MINUTES SECONDS CHARACTER *100LOGIC FLAG PRINT*, ICS101: COMPUTER PROGRAMMING REAL CASH1, CASH2