Information Science 1


 Debra Charles
 9 months ago
 Views:
Transcription
1 Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University
2 Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting programs white spaces comment statements Expressions Arithmetic operators and arithmetic operator precedence Mixedtype arithmetic and type casting Shortcut operators l Quiz 2
3 Recall Week 08 l Compiler, interpreter l Type, data type, ADT l Declaration l Variable l Constant l Literal l Integer, float, char, boolean l Identifier l Assignment statement 3
4 Our goals today l To realize the importance of documenting the source code l To understand how to correctly do arithmetic with computers, using highlevel programming languages l To understand arithmetic operator precedence 4
5 White space l To increase readability of your code, surround operators and operands with white space and skip lines between logical sections of program l Space, tab, and new line are white space characters At least one white space character is required between a keyword (reserved word, operator) and identifier Any amount of white space characters are permitted between identifiers, keywords, operators, and literals 5
6 Comment statements l Comment statements (comments) explain the program to yourself and others There are two types of comments: Block comments Can span several lines Begin with /* and end with */ The compiler ignores everything from /* to */ Line comments Start with // The compiler ignores text from // to the end of line 6
7 Documenting programs l Always include a block comment at the beginning of each source file (new program) identify the author of the program briefly describe the function of the program l Use line and block comments to explain the logic of the program (for example include pseudocode) always explain constants used (there must be no unexplained magic coefficients ) explain algorithm by default assumptions always explain the program I/O (interface) 7
8 l Recall assignment statements: <left side> = <right side> Expressions l An expression is a combination of one or more operators and operands that evaluate to a single value, such that: the value is assigned to left side left side is (must be) a single variable or named constant The value must be compatible with (convertible to) the left side s data type 8
9 Arithmetic expressions l Arithmetic expressions compute numeric results and make use of the arithmetic operators: Operator Operation + addition  subtraction * multiplication / division % modulus (remainder after division) 9
10 Division and remainder If both operands to the division operator / are integers, the result is an integer (the fractional part is discarded), e.g. 14 / 3 equals to 8 / 12 equals to The remainder modulus operator % (or MOD ) returns the remainder after dividing the first operand by the second, e.g. 14 % 3 equals to 2 8 % 12 equals to 8 Taking modulus is an integer operation both operands must be integers
11 % usage examples l Remainder operator is very useful in programming. For example: for any even number q, q % 2 is always 0, and for any odd number p, p % 2 is always 1 l Another example: Suppose we know that January 1 is Saturday. We can then easily calculate that the day for February 1 is Tuesday: Saturday is the 6 th day in a week (Sunday is 0 th ) January has 31 days A week has 7 days All this can be written as: (6+31)%7 that gives 2, the second day in a week which is Tuesday 11
12 Division by zero l Integer division by 0: Example: int x = 4 / 0; l This will result in no compiler error, but at run time, ArithmeticException message (fatal error) will be generated, and the program will stop executing l Floatingpoint division by 0: If dividend is not 0, the result is Infinity If dividend and divisor are both 0, the result is NaN (not a number) 12
13 Operator precedence Precedence Operator Order of evaluation Operation 1 ( ) parenthesis for explicit grouping 2 * / % left  right multiplication, division, modulus left  right addition, subtraction last = right  left assignment Example: x = a / b * (c + (d  e))
14 Expression trees l Sometimes, the evaluation of an expression is convenient to show using an expression tree l The operators lower in the tree have higher precedence for that expression, e.g. a + (b c) / d + a / d b c 14
15 l In most programming languages, when performing calculations with operands of different data types (on right side): Lowerprecision operands are promoted to higherprecision data types, then the calculation is performed Promotion is effective only for expression evaluation and does not cause a permanent change to the data This is called "implicit type casting" l Any expression involving a floatingpoint operand will have a floatingpoint result (on right side) 15 Mixedtype arithmetic
16 16 Rules of promotion Applies the first of these rules that fits: 1. If either operand is a double, the other operand is converted to a double 2. If either operand is a float, the other operand is converted to a float 3. If either operand is a long, the other operand is converted to a long 4. If either operand is an int, the other operand is promoted to an int 5. If neither operand is a double, float, long, or an int, both operands are promoted to int
17 Examples of promotion int x,y; // integers are 4 bytes using 2's compliment format short z; // shorts are 2 bytes using 2's compliment format float a; // floats are 4 bytes, using floating point format x = 7; z = 3; a = 3.14; y = a * 2 + x/z; Explanation: a = 3.14 (floating point number) '2' is integer but is promoted to '2.0' a floating point number z is a short and will be promoted to an integer x/z involves only integers (7/3) so will give a result of 2 (an integer) then the integer 2 will be promoted to 2.0 (a floating point number) calculation: 3.14 * = 8.28 (a floating point number) finally y is assigned an integer 8 since y is an integer data type (the fractional part is removed) 17
18 18 Explicit type casting l Syntax: (datatype)( expression ) l Examples: float x = (float)5/(float)2; int c = (int)(x 3); l Note that parentheses around an expression with no operators have no effect l Casts are useful for calculating averages (think: why?)
19 Shortcut operators l ++ is increment by 1, and  is decrement by 1. Examples: count++; // count = count + 1; count; // count = count  1; l Postfix version (var++, var): use value of var in expression, then increment or decrement l Prefix version (++var, var): increment or decrement var, then use its value in expression 19
20 Examples of shortcuts int x,y,z; x = 2; y = 5; z = x++ + y; // first z is 7; then x = 3 x = 2; y = 5; z = ++x + y; // first x = 3; then z is 8 x = 2; y = 5; z = x y + y/2; /* is y incremented by ++y before or after y is read for the evaluation of y/2? The result is undefined! */ 20
21 Note that no spaces are allowed between the arithmetic operator and the equals sign 21 Other shortcut operators Operator Example Equivalent += a += 3; a = a + 3; = a = 10; a = a  10; *= a *= 4; a = a * 4; /= a /= 7; a = a / 7; %= a %= 10; a = a % 10;
22 22 Operator precedence Precedence 1 ( ) Operator Order of evaluation Operation parenthesis for grouping left  right postincrement, postdecrement right  left preincrement, predecrement 3 * / % left  right multiplication, division, modulus left  right addition or String concatenation, subtraction 5 = += = *= /= %= right  left assignment
23 Real example: C99 operator precedence Precedence Operator Description Associativity Suffix/postfix increment and decrement Lefttoright ( ) Function call [ ] Array subscripting. > Structure and union member access ( type ) { list } Compound literal(c99) Prefix increment and decrement Righttoleft +  Unary plus and minus! ~ Logical NOT and bitwise NOT (type) Type cast * Indirection (dereference) & Addressof sizeof Sizeof 3 * / % Multiplication, division, and remainder Lefttoright Addition and subtraction 5 << >> Bitwise left shift and right shift 6 < <= > >= Relational operators (inequalities) 7 ==!= Relational operators (equalities) 8 & Bitwise AND 9 ^ Bitwise XOR (exclusive or) 10 Bitwise OR (inclusive or) 11 && Logical AND 12 Logical OR 13?: Ternary conditional RighttoLeft 14 = Simple assignment += = Assignment by sum and difference *= /= %= Assignment by product, quotient, and remainder <<= >>= Assignment by bitwise left shift and right shift &= ^= = Assignment by bitwise AND, XOR, and OR 15, Comma Lefttoright 23
24 24 Concepts you need to know after this class l White spaces and comment statements: Why we do need to document programs l Arithmetic expressions: Operators and operator precedence (including shortcuts) l Mixedtype arithmetic rules and type casting
25 25 l Read these slides again l Do the selfpreparation assignments l Learn the vocabulary Homework l Consult, whenever necessary, the textbook materials
26 26 Next class l Boolean expressions Binary logic Relational and logical operators Operator precedence Boolean and algebraic expressions
27 Quiz 04 27
Information Science 1
Topics covered Information Science 1 Terms and concepts from Week 8 Simple calculations Documenting programs Simple Calcula,ons Expressions Arithmetic operators and arithmetic operator precedence Mixedtype
More informationOperators in C. Staff Incharge: S.Sasirekha
Operators in C Staff Incharge: S.Sasirekha Operators An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C
More informationSECTION II: LANGUAGE BASICS
Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators
More informationOperators & Expressions
Operators & Expressions Operator An operator is a symbol used to indicate a specific operation on variables in a program. Example : symbol + is an add operator that adds two data items called operands.
More informationIn Fig. 3.5 and Fig. 3.7, we include some completely blank lines in the pseudocode for readability. programs into their various phases.
Formulating Algorithms with TopDown, Stepwise Refinement Case Study 2: SentinelControlled Repetition In Fig. 3.5 and Fig. 3.7, we include some completely blank lines in the pseudocode for readability.
More informationOperators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur
Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators
More informationChapter 12 Variables and Operators
Chapter 12 Variables and Operators Highlights (1) r. height width operator area = 3.14 * r *r + width * height literal/constant variable expression (assignment) statement 122 Highlights (2) r. height
More informationChapter 2. Elementary Programming
Chapter 2 Elementary Programming 1 Objectives To write Java programs to perform simple calculations To obtain input from the console using the Scanner class To use identifiers to name variables, constants,
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 informationJava provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:
Basic Operators Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationOperators. Lecture 3 COP 3014 Spring January 16, 2018
Operators Lecture 3 COP 3014 Spring 2018 January 16, 2018 Operators Special builtin symbols that have functionality, and work on operands operand an input to an operator Arity  how many operands an operator
More informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
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 informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University January 15, 2015 Chapter 2: Data and Expressions CS 121 1 / 1 Chapter 2 Part 1: Data
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 information3. EXPRESSIONS. It is a sequence of operands and operators that reduce to a single value.
3. EXPRESSIONS It is a sequence of operands and operators that reduce to a single value. Operator : It is a symbolic token that represents an action to be taken. Ex: * is an multiplication operator. Operand:
More informationPART II. Computation
PART II Computation 72 Chapter 4 Expressions Computation is central to computer programming. We discuss how the usual mathematical operations can be applied to variables and introduce the concepts of precedence
More informationLECTURE 3 C++ Basics Part 2
LECTURE 3 C++ Basics Part 2 OVERVIEW Operators Type Conversions OPERATORS Operators are special builtin symbols that have functionality, and work on operands. Operators are actually functions that use
More informationOperators in java Operator operands.
Operators in java Operator in java is a symbol that is used to perform operations and the objects of operation are referred as operands. There are many types of operators in java such as unary operator,
More informationChapter 3 Structure of a C Program
Chapter 3 Structure of a C Program Objectives To be able to list and describe the six expression categories To understand the rules of precedence and associativity in evaluating expressions To understand
More informationProgramming in C++ 5. Integral data types
Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long
More informationChapter 2: Data and Expressions
Chapter 2: Data and Expressions CS 121 Department of Computer Science College of Engineering Boise State University April 21, 2015 Chapter 2: Data and Expressions CS 121 1 / 53 Chapter 2 Part 1: Data Types
More informationChapter 7. Expressions and Assignment Statements ISBN
Chapter 7 Expressions and Assignment Statements ISBN 0321330250 Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions ShortCircuit
More informationCSC 1214: ObjectOriented Programming
CSC 1214: ObjectOriented Programming J. Kizito Makerere University email: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 elearning environment:
More informationESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators
ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 1 IDL Operators ARITHMATIC OPERATORS The assignment operator in IDL is the equals sign, =. IDL uses all the familiar arithmetic operators
More informationChapter 3 Structured Program Development in C Part II
Chapter 3 Structured Program Development in C Part II C How to Program, 8/e, GE 2016 Pearson Education, Ltd. All rights reserved. 1 3.7 The while Iteration Statement An iteration statement (also called
More informationXC Specification. 1 Lexical Conventions. 1.1 Tokens. The specification given in this document describes version 1.0 of XC.
XC Specification IN THIS DOCUMENT Lexical Conventions Syntax Notation Meaning of Identifiers Objects and Lvalues Conversions Expressions Declarations Statements External Declarations Scope and Linkage
More informationObjects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003
Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 Java Programs A Java program contains at least one class definition. public class Hello { public static void
More informationISA 563 : Fundamentals of Systems Programming
ISA 563 : Fundamentals of Systems Programming Variables, Primitive Types, Operators, and Expressions September 4 th 2008 Outline Define Expressions Discuss how to represent data in a program variable name
More informationArithmetic Operators. Portability: Printing Numbers
Arithmetic Operators Normal binary arithmetic operators: +  * / Modulus or remainder operator: % x%y is the remainder when x is divided by y well defined only when x > 0 and y > 0 Unary operators:  +
More informationProgramming in C++ 6. Floating point data types
Programming in C++ 6. Floating point data types! Introduction! Type double! Type float! Changing types! Type promotion & conversion! Casts! Initialization! Assignment operators! Summary 1 Introduction
More informationUnit2 (Operators) ANAND KR.SRIVASTAVA
Unit2 (Operators) ANAND KR.SRIVASTAVA 1 Operators in C ( use of operators in C ) Operators are the symbol, to perform some operation ( calculation, manipulation). Set of Operations are used in completion
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 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 informationChapter 7. Expressions and Assignment Statements
Chapter 7 Expressions and Assignment Statements Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions ShortCircuit Evaluation Assignment
More informationChapter 7. Expressions and Assignment Statements (updated edition 11) ISBN
Chapter 7 Expressions and Assignment Statements (updated edition 11) ISBN 0321493621 Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean
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 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 informationMore Programming Constructs  Introduction
More Programming Constructs  Introduction We can now examine some additional programming concepts and constructs Chapter 5 focuses on: internal data representation conversions between one data type and
More informationContents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual
Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9
More informationCSc 10200! Introduction to Computing. Lecture 23 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 23 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 informationApplied Computer Programming
Applied Computer Programming Representation of Numbers. Bitwise Operators Course 07 Lect.eng. Adriana ALBU, PhD Politehnica University Timisoara Internal representation All data, of any type, processed
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 informationQuick Reference Guide
SOFTWARE AND HARDWARE SOLUTIONS FOR THE EMBEDDED WORLD mikroelektronika Development tools  Books  Compilers Quick Reference Quick Reference Guide with EXAMPLES for Pascal language This reference guide
More informationThe Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Op. Use Description + x + y adds x and y x y
More informationUnitII Programming and Problem Solving (BE1/4 CSE2)
UnitII Programming and Problem Solving (BE1/4 CSE2) Problem Solving: Algorithm: It is a part of the plan for the computer program. An algorithm is an effective procedure for solving a problem in a finite
More informationJava Programming Fundamentals. Visit for more.
Chapter 4: Java Programming Fundamentals Informatics Practices Class XI (CBSE Board) Revised as per CBSE Curriculum 2015 Visit www.ip4you.blogspot.com for more. Authored By: Rajesh Kumar Mishra, PGT (Comp.Sc.)
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba Before writing a program to solve a problem, have a thorough understanding of the problem and a carefully planned approach to solving it. Understand the types of building
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 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 decisionmaking
More informationFall, 2015 Prof. Jungkeun Park
Data Structures t and Algorithms Stacks Application Infix to Postfix Conversion Fall, 2015 Prof. Jungkeun Park Copyright Notice: This material is modified version of the lecture slides by Prof. Rada Mihalcea
More informationInformation Science 1
Information Science 1 Fundamental Programming Constructs (1) Week 11 College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 10 l Flow of control
More informationComputer Programming CS F111
Computer Programming CS F111 BITS Pilani Dubai Campus NAND KUMAR Basics of C Programming BITS Pilani Dubai Campus Write a program that 1. Asks 5 marks from the user, find the average of the marks and print
More informationOperators. Java Primer Operators1 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 informationTopic 4 Expressions and variables
Topic 4 Expressions and variables "Once a person has understood the way variables are used in programming, he has understood the quintessence of programming." Professor Edsger W. Dijkstra Based on slides
More informationLecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions
Lecture 02 Summary C/Java Syntax Keywords Variable Declarations Data Types Operators Statements if, switch, while, dowhile, for Functions 1 2 By the end of this lecture, you will be able to identify the
More informationC/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock)
C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, dowhile, for Functions 2 By the end of this lecture, you will be able to identify the
More informationCS103L FALL 2017 UNIT 1: TYPES, VARIABLES,EXPRESSIONS,C++ BASICS
CS103L FALL 2017 UNIT 1: TYPES, VARIABLES,EXPRESSIONS,C++ BASICS LOGISTICS Homework due tonight and Thursday Should be able to do after reading textbook  go to TA/CP office hours Do the lab Go to lab
More informationJava provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following g roups:
JAVA BASIC OPERATORS http://www.tuto rialspo int.co m/java/java_basic_o perato rs.htm Copyrig ht tutorialspoint.com Java provides a rich set of operators to manipulate variables. We can divide all the
More informationCOMP 110 Introduction to Programming. What did we discuss?
COMP 110 Introduction to Programming Fall 2015 Time: TR 9:30 10:45 Room: AR 121 (Hanes Art Center) Jay Aikat FB 314, aikat@cs.unc.edu Previous Class What did we discuss? COMP 110 Fall 2015 2 1 Today Announcements
More informationWork relative to other classes
Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language
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 informationType Conversion. and. Statements
and Statements Type conversion changing a value from one type to another Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 2 tj Suppose
More informationPerl: Arithmetic, Operator Precedence and other operators. Perl has five basic kinds of arithmetic:
Perl: Arithmetic, Operator Precedence and other operators Robert A. Fulkerson College of Information Science and Technology http://www.ist.unomaha.edu/ University of Nebraska at Omaha http://www.unomaha.edu/
More informationData types, variables, constants
Data types, variables, constants Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic in C 2.6 Decision
More informationC: How to Program. Week /Mar/05
1 C: How to Program Week 2 2007/Mar/05 Chapter 2  Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers
More informationUNIT2 Introduction to C++
UNIT2 Introduction to C++ C++ CHARACTER SET Character set is asset of valid characters that a language can recognize. A character can represents any letter, digit, or any other sign. Following are some
More informationC Language Summary. Chris J Michael 28 August CSC 4103 Operating Systems Fall 2008 Lecture 2 C Summary
Chris J Michael cmicha1@lsu.edu 28 August 2008 C Language Summary Heavily Influenced by the GNU C Reference Manual: http://www.gnu.org/software/gnucmanual/ Introduction C98, or the original ANSI C standard
More informationOn a 64bit CPU. Size/Range vary by CPU model and Word size.
On a 64bit CPU. Size/Range vary by CPU model and Word size. unsigned short x; //range 0 to 65553 signed short x; //range ± 32767 short x; //assumed signed There are (usually) no unsigned floats or doubles.
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All for repetition statement do while repetition statement switch multipleselection statement break statement continue statement Logical
More informationOperators And Expressions
Operators And Expressions Operators Arithmetic Operators Relational and Logical Operators Special Operators Arithmetic Operators Operator Action Subtraction, also unary minus + Addition * Multiplication
More informationChapter 3 Syntax, Errors, and Debugging. Fundamentals of Java
Chapter 3 Syntax, Errors, and Debugging Objectives Construct and use numeric and string literals. Name and use variables and constants. Create arithmetic expressions. Understand the precedence of different
More informationCOMP6700/2140 Operators, Expressions, Statements
COMP6700/2140 Operators, Expressions, Statements Alexei B Khorev and Josh Milthorpe Research School of Computer Science, ANU 3 March 2017 Alexei B Khorev and Josh Milthorpe (RSCS, ANU) COMP6700/2140 Operators,
More informationC++ Programming Basics
C++ Programming Basics Chapter 2 and pp. 634640 Copyright 19982011 Delroy A. Brinkerhoff. All Rights Reserved. CS 1410 Chapter 2 Slide 1 of 25 Program Components Function main P Every C/C++ program has
More informationSoftware II: Principles of Programming Languages. Why Expressions?
Software II: Principles of Programming Languages Lecture 7 Expressions and Assignment Statements Why Expressions? Expressions are the fundamental means of specifying computations in a programming language
More informationC Programming
204216  C Programming Chapter 3 Processing and Interactive Input Adapted/Assembled for 204216 by Areerat Trongratsameethong A First Book of ANSI C, Fourth Edition Objectives Assignment Mathematical Library
More informationChapter 7. Expressions and Assignment Statements
Chapter 7 Expressions and Assignment Statements Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions ShortCircuit Evaluation Assignment
More informationCMSC 104 Lecture 6 John Y. Park, adapted by C Grasso
CMSC 104 Lecture 6 John Y. Park, adapted by C Grasso 1 Topics #define Arithmetic Operators Assignment Operators Operator Precedence Evaluating Arithmetic Expressions Incremental Programming 2 Preprocessor
More informationData Conversion & Scanner Class
Data Conversion & Scanner Class Quick review of last lecture August 29, 2007 ComS 207: Programming I (in Java) Iowa State University, FALL 2007 Instructor: Alexander Stoytchev Numeric Primitive Data Storing
More informationECEN 468 Advanced Logic Design
ECEN 468 Advanced Logic Design Lecture 26: Verilog Operators ECEN 468 Lecture 26 Operators Operator Number of Operands Result Arithmetic 2 Binary word Bitwise 2 Binary word Reduction 1 Bit Logical 2 Boolean
More informationLESSON 5 FUNDAMENTAL DATA TYPES. char short int long unsigned char unsigned short unsigned unsigned long
LESSON 5 ARITHMETIC DATA PROCESSING The arithmetic data types are the fundamental data types of the C language. They are called "arithmetic" because operations such as addition and multiplication can be
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 informationC++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.
EEE117 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 informationCS 33. Data Representation, Part 2. CS33 Intro to Computer Systems VIII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Data Representation, Part 2 CS33 Intro to Computer Systems VIII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Numeric Ranges Unsigned Values UMin = 0 000 0 UMax = 2 w 1 111 1 Two s Complement
More informationBoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)
BoredGames Language Reference Manual A Language for Board Games Brandon Kessler (bpk2107) and Kristen Wise (kew2132) 1 Table of Contents 1. Introduction... 4 2. Lexical Conventions... 4 2.A Comments...
More informationWhat we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements
Topic 4 Variables Once a programmer has understood the use of variables, he has understood the essence of programming Edsger Dijkstra What we will do today Explain and look at examples of primitive data
More informationJAC444  Lecture 1. Introduction to Java Programming Language Segment 4. Jordan Anastasiade Java Programming Language Course
JAC444  Lecture 1 Introduction to Java Programming Language Segment 4 1 Overview of the Java Language In this segment you will be learning about: Numeric Operators in Java Type Conversion If, For, While,
More informationESc101 : Fundamental of Computing
ESc101 : Fundamental of Computing I Semester 200809 Lecture 9+10 Types Range of numeric types and literals (constants) in JAVA Expressions with values of mixed types 1 I : Range of numeric types and literals
More informationChapter 2  Introduction to C Programming
Chapter 2  Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers 2.4 Memory Concepts 2.5 Arithmetic
More informationHAWK Language Reference Manual
HAWK Language Reference Manual HTML is All We Know Created By: Graham Gobieski, George Yu, Ethan Benjamin, Justin Chang, Jon Adelson 0. Contents 1 Introduction 2 Lexical Convetions 2.1 Tokens 2.2 Comments
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 informationLanguage Fundamentals Summary
Language Fundamentals Summary Claudia Niederée, Joachim W. Schmidt Software Systems Institute Objectoriented Analysis and Design 1998/99 c.niederee@tuharburg.de http://www.sts.tuharburg.de Keywords
More informationModule 2 Introducing Data Types and Operators
Module 2 Introducing Data Types and Operators Table of Contents CRITICAL SKILL 2.1: The C++ Data Types... 2 Project 21 Talking to Mars... 10 CRITICAL SKILL 2.2: Literals... 12 CRITICAL SKILL 2.3: A Closer
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, AddisonWesley Inc. Publishing as Pearson AddisonWesley
More informationLanguage Fundamentals Summary
Language Fundamentals Summary Claudia Niederée, Joachim W. Schmidt, Michael Skusa Software Systems Institute Objectoriented Analysis and Design 1999/2000 c.niederee@tuharburg.de http://www.sts.tuharburg.de
More informationMODULE 02: BASIC COMPUTATION IN JAVA
MODULE 02: BASIC COMPUTATION IN JAVA Outline Variables Naming Conventions Data Types Primitive Data Types Review: int, double New: boolean, char The String Class Type Conversion Expressions Assignment
More information4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning
4 Operations On Data 4.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List the three categories of operations performed on data.
More informationChapter 3. Numeric Types, Expressions, and Output
Chapter 3 Numeric Types, Expressions, and Output 1 Chapter 3 Topics Constants of Type int and float Evaluating Arithmetic Expressions Implicit Type Coercion and Explicit Type Conversion Calling a ValueReturning
More informationIntroduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.
Introduction to Visual Basic and Visual C++ Arithmetic Expression Lesson 4 Calculation I1541A A @ Peter Lo 2010 1 I1541A A @ Peter Lo 2010 2 Arithmetic Expression Using Arithmetic Expression Calculations
More informationBuilding Java Programs
Building Java Programs Chapter 2 Lecture 21: Expressions and Variables reading: 2.12.2 Copyright 2009 by Pearson Education Data and expressions reading: 2.1 selfcheck: 14 videos: Ch. 2 #1 Copyright
More information