Lesson 02 Working with Data Types. MIT 31043: VISUAL PROGRAMMING By: S. Sabraz Nawaz Senior Lecturer in MIT
|
|
- Mae Rose
- 6 years ago
- Views:
Transcription
1 Lesson 02 Working with Data Types MIT 31043: VISUAL PROGRAMMING Senior Lecturer in MIT
2 Variables A variable is a storage location in memory that is represented by a name. A variable stores data, which are processed with statements. A program is a list of statements that manipulate variables. To write even simple applications, you need a basic understanding of some fundamental topics, such as the data types (the kind of data you can store in a variable), the scope and lifetime of variables, and how to write procedures and pass arguments to them. A variable has a name and a value. The variable UserName, for example, can have the value MIT, and the variable Salary can have the value UserName and Salary are variable names, and MIT and are their values. MIT is a string (that is, text or an alphanumeric value), and is a numeric value. When a variable s value is a string, it must be enclosed in double quotes. In your code, you can refer to the value of a variable by the variable s name. In addition to a name and a value, variables have a data type, which determines what kind of values we can store to a variable. C# supports several data types. The data type of a variable is specified when the variable is declared, and you should always declare variables before using them. Slide 2
3 Naming variables You should adopt a naming convention for variables that helps you to avoid confusion concerning the variables you have defined. This is especially important if you are part of a project team with several developers working on different parts of an application; a consistent naming convention helps to avoid confusion and can reduce the scope for bugs. The following list contains some general recommendations: o In a multiword identifier, start the second and each subsequent word with an uppercase letter. (This is called camelcasenotation.) o Don t start an identifier with an underscore o Don t create identifiers that differ only by case. For example, myvariable and MyVariable o Start the name with a lowercase letter. Slide 3
4 Declaring variables In most programming languages, variables must be declared in advance. Historically, the reason for doing this has been to help the compiler generate the most efficient code. If the compiler knows all the variables and their types ahead of time, it can produce the most compact and efficient, or optimized, code. You declare the type and name of a variable in a declaration statement. int age; The variable type int is the name of one of the primitive C# types, integer, which is a whole number. After declaring, you can assign it a value. age = 38; Slide 4
5 Data Types: Integer Types TYPE ALLOWED VALUES sbyte Integer between 128 and 127 byte Integer between 0 and 255 short Integer between and ushort Integer between 0 and int Integer between and uint Integer between 0 and long Integer between and ulong Integer between 0 and The u characters before some variable names are shorthand for unsigned, meaning that you can t store negative numbers in variables of those types, as shown in the Allowed Values column of the preceding table. Slide 5
6 Data Types: Floating-point Types TYPE APPROX MIN VALUE APPROX MAX VALUE float double decimal Slide 6
7 Data Types: Text and Boolean Types TYPE char bool string ALLOWED VALUES Single Unicode character, stored as an integer between 0 and Boolean value, true or false A sequence of characters Slide 7
8 Syntax type variablename = value; Examples int intcounter = 1; Declaring variables long lngnumberofbytes = 20000; float fltinterestrate = 8.125f; // f or F indicates a float value double dblprice = 14.95; decimal dectotal = m; // m or M indicates a decimal value char chrletter = 'A'; // enclose a character value in single quotes bool blnvalid = false; int intx = 0, inty = 0; // initialize 2 variables with 1 statement Slide 8
9 Named Constant A named constant is a name that represents a value that cannot be changed during the program s execution. Assume that the following statement appears in a banking program that calculates data pertaining to loans: o amount = balance * 0.069; Two potential problems arise: o First, it is not clear to anyone other than the original programmer what is. o The second problem occurs if this number is used in other calculations throughout the program and must be changed periodically. Slide 9
10 Declaring Constants How to declare and initialize a constant Syntax const type CONSTANT_NAME = value; Examples const int DAYS_IN_NOVEMBER = 30; const decimal SALES_TAX =.075m; Naming conventions Capitalize all letters for each word of a constant name, separating with underscores. Slide 10
11 Arithmetic Operators Operator Name Description + Addition Adds two operands. - Subtraction Subtracts the right operand from the left operand. * Multiplication Multiplies the right operand and the left operand. / Division Divides the right operand into the left operand. If both operands are integers, then the result is an integer. % Modulus Returns the value that is left over after dividing the right operand into the left operand. Slide 11
12 Arithmetic operators (continued) Operator Name Description + Positive sign Returns the value of the operand. - Negative sign Changes a positive value to negative, and vice versa. ++ Increment Adds 1 to the operand (x = x + 1). -- Decrement Subtracts 1 from the operand (x = x - 1). Slide
13 Assignment Operators Operator Name = Assignment += Addition -= Subtraction *= Multiplication /= Division %= Modulus Slide 13
14 Assignment Operators The syntax for a simple assignment statement variablename = expression; Typical assignment statements intcounter = 7; intnewcounter = intcounter; decdiscountamount = decsubtotal *.2m; dectotal = decsubtotal decdiscountamount; Slide 14
15 Assignment Operators Statements that use the same variable on both sides of the equals sign dectotal = dectotal + 100m; dectotal = dectotal 100m; decprice = decprice *.8m; Statements that use the shortcut assignment operators dectotal += 100m; dectotal -= 100m; decprice *=.8m; Slide
16 The order of precedence for arithmetic operations 1. Increment and decrement 2. Positive and negative 3. Multiplication, division, and modulus 4. Addition and subtraction Slide 16
17 Common methods for data conversion Method Description ToString([format]) A method that converts the value to its equivalent string representation using the specified format. If the format is omitted, the value isn t formatted. Parse(string) A static method that converts the specified string to an equivalent data value. Slide
18 Sample ToString formats Variable Value Format specifier code Output totaldecimal ToString("C" ) $1, totaldecimal ToString("N") 1, totaldecimal ToString(" N0 ") 1,126 balancedecimal ToString(" N3 ") 1, balancedecimal ToString(" F0 ") 1126 pininteger 123 ToString(" D6 ") ratedecimal ToString(" P " ) 7.50 % ratedecimal ToString(" P3 ") % ratedecimal ToString(" P0 ") 8 % valueinteger 10 ToString(" C " ) ($10.00) valueinteger 10 ToString(" N " ) valueinteger 10 ToString(" D3 ) 010 Code Formats C or c Currency, P or p Percent, N or n Number, F or f Float, D or d Digits, E or e Exponential, G or g General Slide 18
19 Some of the static methods of the Convert class Method ToDecimal(value) ToDouble(value) ToInt32(value) ToChar(value) ToBool(value) ToString(value) Description Converts the value to the decimal data type. Converts the value to the double data type. Converts the value to the int data type. Converts the value to the char data type. Converts the value to the bool data type. Converts the value to the string data type. Slide
20 Statements that use ToString and Parse decimal decsales = m; string strsalesstring = decsales.tostring(); // decimal to string decsales = Decimal.Parse(strSalesString); // string to decimal Conversion statements that use the Convert class decimal decsubtotal = Convert.ToDecimal(txtSubtotal.Text); // string to decimal int intyears = Convert.ToInt32(txtYears.Text); // string to int txtsubtotal.text = Convert.ToString(decSubtotal); // decimal to string int subtotalint = Convert.ToInt32(decSubtotal); // decimal to int
21 Practical Exam - 01 Write a Visual C# program that takes Amount as input and displays the possible currency denominations as output. Currency denominations are 5000/=, 2000/=, 1000/=, 500/=, 100/=, 50/=, 20/=, 10/= and Coins. Practice 02: By. SaNa 21
22 Interface Design Practice 02: By. SaNa 22
23 Practice Practice 02: By. SaNa 23
24 Interface Design basicsalarytextbox otratetextbox othourstextbox loantextbox bonustextbox allowancetextbox netsalarytextbox Practice 02: By. SaNa 24
25 Codes Practice 02: By. SaNa 25
26 Codes (casting) Practice 02: By. SaNa 26
27 Design the form as below Ex 01 Slide
28 Ex 01 Double click on Convert button and add the following code Slide
29 Ex 01 Double click on Clear button and add the following code Double click on Exit button and add the following code Slide
30 Ex 02: Invoice Total Slide
31 Ex 02: Code Slide
32 Understanding Numeric Type Conversion When you perform arithmetic with variables or constants of the same type, the result of the arithmetic retains the same type. For example, when you divide two ints, the result is an int; when you subtract two doubles, the result is a double. Often, however, you need to perform mathematical operations on different types. For example, in the following code, you multiply an int by a double: o int hoursworked = 36; o double payrate = 12.35; o double grosspay = hoursworked * payrate; Slide 34
33 Understanding Numeric Type Conversion When you perform arithmetic operations with operands of dissimilar types, C# chooses a unifying type for the result and implicitly (or automatically) converts nonconforming operands to the unifying type, which is the type with the higher type precedence. The conversion is called an implicit conversion or an implicit cast the automatic transformation that occurs when a value is assigned to a type with higher precedence. For example, if you multiply an int and a double, the result is implicitly a double. This requirement means the result must be stored in a double; if you attempt to assign the result to an int, you will receive a compiler error message like the one shown in Figure. Slide 35
34 Understanding Numeric Type Conversion Error message received when trying to compile a program that attempts to store a double in an int The error message in figure asks are you missing a cast? You may explicitly (or purposefully) override the unifying type imposed by C# by performing an explicit cast. An explicit cast involves placing the desired result type in parentheses followed by the variable or constant to be cast, as shown below Slide 36
35 Understanding Numeric Type Conversion Another example is shown here o The value of bankbalance / 4 is implicitly a double because a double divided by an int produces a double. o The double result is then converted to a float before it is stored in weeklybudget. o The float value weeklybudget is converted to an int before it is stored in rupees. o When the float value is converted to an int, the decimal-place values are lost. Implicit conversions are not always the result of arithmetic calculations; simple assignments often result in implicit conversions. For example, if money is declared as a double, then the following statement implicitly converts the integer 15 to a double: o double money; o money = 15; Slide 37
36 The implicit numeric conversions From sbyte short, int, long, float, double, or decimal From byte short, ushort, int, uint, long, ulong, float, double, or decimal From short int, long, float, double, or decimal From ushort int, uint, long, ulong, float, double, or decimal From int long, float, double, or decimal From uint long, ulong, float, double, or decimal From long float, double, or decimal From ulong float, double, or decimal From char ushort, int, uint, long, ulong, float, double, or decimal From float double Slide 38
37 End
Lesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz
Lesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT Faculty of Management and Commerce South Eastern University of Sri Lanka Variables
More informationVisual C# Instructor s Manual Table of Contents
Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms
More informationChapter 2: Using Data
Chapter 2: Using Data Declaring Variables Constant Cannot be changed after a program is compiled Variable A named location in computer memory that can hold different values at different points in time
More informationMurach s Visual Basic 2012, C4 2013, Mike Murach & Associates, Inc. Slide 1. The built-in value types (continued)
The built-in value types Keyword Bytes Type Description Byte 1 Byte Positive integer value from 0 to 255 SByte 1 SByte Signed integer value from -128 to 127 Short 2 Int16 Integer from 32,768 to +32,767
More informationCIS 3260 Intro to Programming with C#
Variables, Constants and Calculations McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Define a variable Distinguish between variables, constants, and control objects Differentiate
More informationLesson 02 Data Types and Statements. MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL
Lesson 02 Data Types and Statements MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL Topics Covered Statements Variables Constants Data Types
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
More informationCOMP Primitive and Class Types. Yi Hong May 14, 2015
COMP 110-001 Primitive and Class Types Yi Hong May 14, 2015 Review What are the two major parts of an object? What is the relationship between class and object? Design a simple class for Student How to
More informationBASIC ELEMENTS OF A COMPUTER PROGRAM
BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting
More informationLesson 02 Data Types and Statements. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL
Lesson 02 Data Types and Statements MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL Topics Covered Statements Variables Data Types Arithmetic
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics
Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional
More informationFull file at
Java Programming, Fifth Edition 2-1 Chapter 2 Using Data within a Program At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
More informationLECTURE 3 C++ Basics Part 2
LECTURE 3 C++ Basics Part 2 OVERVIEW Operators Type Conversions OPERATORS Operators are special built-in symbols that have functionality, and work on operands. Operators are actually functions that use
More informationDeclaration and Memory
Declaration and Memory With the declaration int width; the compiler will set aside a 4-byte (32-bit) block of memory (see right) The compiler has a symbol table, which will have an entry such as Identifier
More informationReserved Words and Identifiers
1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the
More informationObjectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments
Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify
More informationData and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence
Data and Variables Data Types Expressions Operators Precedence String Concatenation Variables Declaration Assignment Shorthand operators Review class All code in a java file is written in a class public
More informationOperators. Lecture 3 COP 3014 Spring January 16, 2018
Operators Lecture 3 COP 3014 Spring 2018 January 16, 2018 Operators Special built-in symbols that have functionality, and work on operands operand an input to an operator Arity - how many operands an operator
More informationEx: If you use a program to record sales, you will want to remember data:
Data Variables Programs need to remember values. Ex: If you use a program to record sales, you will want to remember data: A loaf of bread was sold to Sione Latu on 14/02/19 for T$1.00. Customer Name:
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationValues and Variables 1 / 30
Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides
More informationChapter 2 Working with Data Types and Operators
JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationModule 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1
Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1 Topics 1. Expressions 2. Operator precedence 3. Shorthand operators 4. Data/Type Conversion 1/15/19 CSE 1321 MODULE 2 2 Expressions
More informationUnderstand Computer Storage and Data Types
Understand Computer Storage and Data Types Lesson Overview Students will understand computer storage and data types. In this lesson, you will learn: How a computer stores programs and instructions in computer
More informationFundamentals of Programming
Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationCSE 1001 Fundamentals of Software Development 1. Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018
CSE 1001 Fundamentals of Software Development 1 Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018 Identifiers, Variables and Data Types Reserved Words Identifiers in C Variables and Values
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:
Java Programming, Eighth Edition 2-1 Chapter 2 Using Data A Guide to this Instructor s Manual: We have designed this Instructor s Manual to supplement and enhance your teaching experience through classroom
More informationMidterms Save the Dates!
University of British Columbia CPSC 111, Intro to Computation Alan J. Hu Primitive Data Types Arithmetic Operators Readings Your textbook is Big Java (3rd Ed). This Week s Reading: Ch 2.1-2.5, Ch 4.1-4.2.
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationZheng-Liang Lu Java Programming 45 / 79
1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 45 / 79 Example Given a radius
More informationChapter 02: Using Data
True / False 1. A variable can hold more than one value at a time. ANSWER: False REFERENCES: 54 2. The int data type is the most commonly used integer type. ANSWER: True REFERENCES: 64 3. Multiplication,
More informationProgramming Language 2 (PL2)
Programming Language 2 (PL2) 337.1.1 - Explain rules for constructing various variable types of language 337.1.2 Identify the use of arithmetical and logical operators 337.1.3 Explain the rules of language
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationIntroduction to Programming EC-105. Lecture 2
Introduction to Programming EC-105 Lecture 2 Input and Output A data stream is a sequence of data - Typically in the form of characters or numbers An input stream is data for the program to use - Typically
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationJava Notes. 10th ICSE. Saravanan Ganesh
Java Notes 10th ICSE Saravanan Ganesh 13 Java Character Set Character set is a set of valid characters that a language can recognise A character represents any letter, digit or any other sign Java uses
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
More informationAdvanced Computer Programming
Hazırlayan Yard. Doç. Dr. Mehmet Fidan VARIABLE TYPES Integral Types: In C#, an integral is a category of types. For anyone confused because the word Integral sounds like a mathematical term, from the
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationBy the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program
1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize
More informationREVIEW. The C++ Programming Language. CS 151 Review #2
REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,
More informationFundamentals of Programming CS-110. Lecture 2
Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout
More informationFRAC: Language Reference Manual
FRAC: Language Reference Manual Justin Chiang jc4127 Kunal Kamath kak2211 Calvin Li ctl2124 Anne Zhang az2350 1. Introduction FRAC is a domain-specific programming language that enables the programmer
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationLECTURE 02 INTRODUCTION TO C++
PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION
More informationCSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI
CSCI 2010 Principles of Computer Science Data and Expressions 08/09/2013 CSCI 2010 1 Data Types, Variables and Expressions in Java We look at the primitive data types, strings and expressions that are
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationArithmetic Operations
232 Chapter 4 Variables and Arithmetic Operations Arithmetic Operations The ability to perform arithmetic operations on numeric data is fundamental to computer programs. Many programs require arithmetic
More informationProgramming Lecture 3
Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements
More informationComputational Expression
Computational Expression Variables, Primitive Data Types, Expressions Janyl Jumadinova 28-30 January, 2019 Janyl Jumadinova Computational Expression 28-30 January, 2019 1 / 17 Variables Variable is a name
More informationOutline. Data and Operations. Data Types. Integral Types
Outline Data and Operations Data Types Arithmetic Operations Strings Variables Declaration Statements Named Constant Assignment Statements Intrinsic (Built-in) Functions Data and Operations Data and Operations
More informationProgramming with Java
Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules
More informationCMPT 125: Lecture 3 Data and Expressions
CMPT 125: Lecture 3 Data and Expressions Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 1 Character Strings A character string is an object in Java,
More informationAn Introduction to Processing
An Introduction to Processing Variables, Data Types & Arithmetic Operators Produced by: Dr. Siobhán Drohan Mairead Meagher Department of Computing and Mathematics http://www.wit.ie/ Topics list Variables.
More informationChapter 2 Elementary Programming
Chapter 2 Elementary Programming Part I 1 Motivations In the preceding chapter, you learned how to create, compile, and run a Java program. Starting from this chapter, you will learn how to solve practical
More informationDifferentiate Between Keywords and Identifiers
History of C? Why we use C programming language Martin Richards developed a high-level computer language called BCPL in the year 1967. The intention was to develop a language for writing an operating system(os)
More informationCS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University
CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics 1 Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-3 2.1 Variables and Assignments 2
More informationLecture 2 Tao Wang 1
Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors
More informationDEPARTMENT OF MATHS, MJ COLLEGE
T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
More informationWill introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators
Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships
More informationLe L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators
Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One
More informationChapter 2. C++ Basics
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-2 2.1 Variables and Assignments Variables
More informationPrimitive Types. Four integer types: Two floating-point types: One character type: One boolean type: byte short int (most common) long
Primitive Types Four integer types: byte short int (most common) long Two floating-point types: float double (most common) One character type: char One boolean type: boolean 1 2 Primitive Types, cont.
More informationCS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation
CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;
More informationVariables and Operators 2/20/01 Lecture #
Variables and Operators 2/20/01 Lecture #6 16.070 Variables, their characteristics and their uses Operators, their characteristics and their uses Fesq, 2/20/01 1 16.070 Variables Variables enable you to
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationChapter 2 ELEMENTARY PROGRAMMING
Chapter 2 ELEMENTARY PROGRAMMING Lecture notes for computer programming 1 Faculty of Engineering and Information Technology Prepared by: Iyad Albayouk ١ Objectives To write Java programs to perform simple
More informationCSC Web Programming. Introduction to JavaScript
CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its
More informationMicrosoft Visual Basic 2005: Reloaded
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named
More informationValues, Variables, Types & Arithmetic Expressions. Agenda
Values, Variables, Types & Arithmetic Expressions Lecture 2 Object-Oriented Programming Agenda Inside of a Computer Value Variable Data Types in Java Literals Identifiers Type conversions Manipulating
More informationChapter 2: Introduction to C++
Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++
More informationChapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lesson 02 Variables and Operators Agenda Variables Types Naming Assignment Data Types Type casting Operators
More informationARG! Language Reference Manual
ARG! Language Reference Manual Ryan Eagan, Mike Goldin, River Keefer, Shivangi Saxena 1. Introduction ARG is a language to be used to make programming a less frustrating experience. It is similar to C
More information.Net Technologies. Components of.net Framework
.Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.
More informationSir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )
Sir Muhammad Naveed Arslan Ahmed Shaad (1163135 ) Muhammad Bilal ( 1163122 ) www.techo786.wordpress.com CHAPTER: 2 NOTES:- VARIABLES AND OPERATORS The given Questions can also be attempted as Long Questions.
More information1.3b Type Conversion
1.3b Type Conversion Type Conversion When we write expressions involved data that involves two different data types, such as multiplying an integer and floating point number, we need to perform a type
More information2/5/2018. Expressions are Used to Perform Calculations. ECE 220: Computer Systems & Programming. Our Class Focuses on Four Types of Operator in C
University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming Expressions and Operators in C (Partially a Review) Expressions are Used
More informationC++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.
EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic
More informationJava Primer 1: Types, Classes and Operators
Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style 3 2.1 Variables and Assignments Variables and
More information2/29/2016. Definition: Computer Program. A simple model of the computer. Example: Computer Program. Data types, variables, constants
Data types, variables, constants Outline.1 Introduction. Text.3 Memory Concepts.4 Naming Convention of Variables.5 Arithmetic in C.6 Type Conversion Definition: Computer Program A Computer program is a
More informationBasic data types. Building blocks of computation
Basic data types Building blocks of computation Goals By the end of this lesson you will be able to: Understand the commonly used basic data types of C++ including Characters Integers Floating-point values
More informationA First Program - Greeting.cpp
C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout
More informationENGR 101 Engineering Design Workshop
ENGR 101 Engineering Design Workshop Lecture 2: Variables, Statements/Expressions, if-else Edgardo Molina City College of New York Literals, Variables, Data Types, Statements and Expressions Python as
More informationOperators. Java Primer Operators-1 Scott MacKenzie = 2. (b) (a)
Operators Representing and storing primitive data types is, of course, essential for any computer language. But, so, too, is the ability to perform operations on data. Java supports a comprehensive set
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationLecture 3 Tao Wang 1
Lecture 3 Tao Wang 1 Objectives In this chapter, you will learn about: Arithmetic operations Variables and declaration statements Program input using the cin object Common programming errors C++ for Engineers
More informationBEGINNING PROBLEM-SOLVING CONCEPTS FOR THE COMPUTER. Chapter 2
1 BEGINNING PROBLEM-SOLVING CONCEPTS FOR THE COMPUTER Chapter 2 2 3 Types of Problems that can be solved on computers : Computational problems involving some kind of mathematical processing Logical Problems
More informationLecture 2: Variables and Operators. AITI Nigeria Summer 2012 University of Lagos.
Lecture 2: Variables and Operators AITI Nigeria Summer 2012 University of Lagos. Agenda Variables Types Naming Assignment Data Types Type casting Operators Declaring Variables in Java type name; Variables
More information