Simple Data Types and Statements. Namespaces namespace MyNamespace { // …. { MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx.

Slides:



Advertisements
Similar presentations
ספטמבר 04Copyright Meir Kalech1 C programming Language Chapter 1: Types, Operators and Expressions.
Advertisements

IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
©2004 Brooks/Cole Chapter 2 Variables, Values and Operations.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
1 Fundamental Data types Overview l Primitive Data Types l Variable declaration l Arithmetical Operations l Expressions l Assignment statement l Increment.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
All the Operators. Precedence An operator with higher precedence is done earlier (prededes) one with lower precedence –A higher precedence is indicated.
1 Data types, operations, and expressions Overview l Primitive Data Types l Variable declaration l Arithmetical Operations l Expressions.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
Data types and variables
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
0 Chap. 2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations Imperative Programming, B. Hirsbrunner,
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
Primitive Types CSE 115 Spring 2006 April 3 &
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
Chapter 2 Data Types, Declarations, and Displays
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
2015/8/221 Data Types & Operators Lecture from (Chapter 3,4)
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
Objectives You should be able to describe: Data Types
Chapter 2: Introducing Data Types and Operators.  Know Java’s primitive types  Use literals  Initialize variables  Know the scope rules of variables.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Outline Variables 1.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
Primitive Data Types and Operations Identifiers, Variables, and Constants Primitive Data Types Byte, short, int, long, float, double, char, boolean Casting.
 Input and Output Functions Input and Output Functions  OperatorsOperators Arithmetic Operators Assignment Operators Relational Operators Logical Operators.
2440: 211 Interactive Web Programming Expressions & Operators.
1 Do you have a CS account? Primitive types –“ building blocks ” for more complicated types Java is strongly typed –All variables in a Java program must.
Operators Using Java operators An operator takes one or more arguments and produces a new value. All operators produce a value from their.
Chapter 2: Using Data.
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
Knowledge Base C++ #include using std namespace; int main(){} return 0 ; cout
C Programming Lecture 6 : Operators Lecture notes : courtesy of Ohio Supercomputing Center, and Prof. Woo and Prof. Chang.
C++ Basics Tutorial 6 Operators. What are going to see today? Assignment operator(=) Arithmetic operators(+,-,*,/,%) Compound assignment(+=,-=,*=……..)
C Operators. CONTENTS C OPERATORS TYPES OF OPERATOR UNARY BINARY TERNARY ARITHMATIC RELATIONAL LOGICAL.
Java operatoriai sandbolts/operators.html
Operators Precedence - Operators with the highest precedence will be executed first. Page 54 of the book and Appendix B list C's operator precedence. Parenthesis.
15-Nov-15 All the Operators. operators.ppt 2 Precedence An operator with higher precedence is done earlier (precedes) one with lower precedence A higher.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Primitive Variables.
COMP Primitive and Class Types Yi Hong May 14, 2015.
Operators in JAVA. Operator An operator is a symbol that operates on one or more arguments to produce a result. Java provides a rich set of operators.
Expressions and Operators in C. Expressions and Operators Examples: 3 + 5; x; x=0; x=x+1; printf("%d",x); Two types: – Function calls – The expressions.
Operators & Expressions
0 Chap.2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations 2.5Arithmetic Operators 2.6Relational.
Department of Electronic & Electrical Engineering Expressions operators operands precedence associativity types.
What are Operators? Some useful operators to get you started.
ECE 103 Engineering Programming Chapter 4 Operators Herbert G. Mayer, PSU CS Status 6/19/2015 Initial content copied verbatim from ECE 103 material developed.
Expression and Operator. Expressions and Operators u Examples: 3 + 5; x; x=0; x=x+1; printf("%d",x); u Two types: –Function calls –The expressions formed.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Quick Summary C++/CLI Basics Data Types Controls Arrays In-class assignments.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
1Object-Oriented Program Development Using C++ Built-in Data Types Data type –Range of values –Set of operations on those values Literal: refers to acceptable.
Primitive Data Types and Operations F Introduce Programming with an Example F Identifiers, Variables, and Constants F Primitive Data Types –byte, short,
1 Chapter 3 – Operators and Expressions Outline 3.1Introduction 3.2Arithmetic operators 3.3Relational operators 3.4Logical operators 3.5Assignment operators.
Relational Operator and Operations
C++ Programming Language Lecture 4 C++ Basics – Part II
CSE 220 – C Programming Expressions.
INSPIRING CREATIVE AND INNOVATIVE MINDS
2.0 FUNDAMENTALS OF JAVA PROGRAMMING LANGUAGE
Java operatoriai
Operators and Expressions
Operators and Expressions
Lecture 5 from (Chapter 4, pages 73 to 96)
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Introduction to Programming – 4 Operators
C++ Programming Language Lecture 4 C++ Basics – Part II
Operator and Expression
ECE 120 Midterm 1 HKN Review Session.
Presentation transcript:

Simple Data Types and Statements

Namespaces namespace MyNamespace { // …. { MyNamespace::func1() using namespace OtherNamespace; Comments: // /* xxxx */

Basic Data Types Type Range Literals/constants and variables Operators and expressions Assignment Input and output

Primitive Data Types in C++/CLI Integer: –Int16 (short); UInt16 (unsinged short) –Int32 (int or long); UInt32(unsigned int or long) –Int64 (long long); UInt64(unsigned long long, _int64) int x, y(1), z = 123; //(signed, 32 bits) Console::WriteLine(0x10); Console::WriteLine(-0x10); // negative hex 10 is base Floating: –Single (float, 32bits) –Double (double, 64bits)

Primitive Data Types in C++/CLI Boolean (bool, true or false) Character (Char, 16bits, unsigned unicode) –Character and escape sequence char a = ‘A’; // character ‘A’ Char b = L‘A’; // unicode ‘A’ Char c = L‘\x0041’; // hex 41 is ASCII ‘A’ char d = ‘\t’; // tab escape Char e = L‘\\’; // unicode backslash escape

Arithmetic Operators + addition - subtraction * multiplication / division % remainder or modulus

Arithmetic Expression(informal and Inexhaustible) A constant is an expression. A variable is an expression. If P and Q are expressions, and ☺ is a binary operator, then P☺Q is an expression. An expression has a type too.

Unary Operators +, plus -, minus ++, increment --, decrement

Relational Operators == equal to != not equal to > greater than >= greater than or equal to < less than <= less than or equal to

Bitwise and Shift Operators ~, unary bitwise complement &, bitwise AND |, bitwise OR ^, bitwise exclusive OR <<, shift left >>, shift right

Logical Operators &&, AND ||, OR !, NOT

Precedence and Associativity ++, --, unary minus, !, ~ *, /, % +, - >, >= ==, != & ^ | && || ?: =, +=, …

++d, d++: (++d –e) be ++d then - e (d++ - e) be: d-b then d++ int a = 2; int b = 3; int c = (b++,a = b++ * a++, a%b); Be: b++, a*b, b++, a++, a%b Bitwise 0101 & 0011 be | 0011 be ^ 0011 be 0110 ~0101 be >> 2 be (two positions, /4) << 1 be (one, *2) a = a+5; b = b*2; be a += 5; b *= 2; More examples:

Expressions and Assignments y=a*x*x+b*x+c; y=(a*x+b)*x+c; n=7/3; n=7%3; z=x+y/2; z=(x+y)/2; i=i+1; i += 1; i++;

More Expressions x>=0 x+y > 3*z+5 x>=0 && x<=100 x 100 bFound != Found;

Ternary Operator X?Y:Z (grade>=60)?1:0

Examples Quadratic Equation: ax 2 +bx+c=0 Discriminant: ∆=b 2 -4ac Two roots: x 1 = x 2 = Math class: System::Math::Sqrt(discriminant)