Declaration. Fundamental Data Types. Modifying the Basic Types. Basic Data Types. All variables must be declared before being used.

Size: px
Start display at page:

Download "Declaration. Fundamental Data Types. Modifying the Basic Types. Basic Data Types. All variables must be declared before being used."

Transcription

1 Declaration Fundamental Data Types All variables must be declared before being used. Tells compiler to set aside an appropriate amount of space in memory to hold a value. Enables the compiler to perform operations using the declared variables. 1 2 char int float double void Basic Data Types character integer floating-point double floating-point valueless 3 Modifying the Basic Types Type modifier: signed unsigned long short When a type modifier is used by itself, then int is assumed. Modifier Same As signed signed int unsigned unsigned int long long int short short int 4 Data Type char Have Seen:Chars are treated as small integers & conversely small ints are treated as chars. char c = a ; a printf ( %c, c + 1) printf ( %d, c + 2) 99 Each char variable stored in 1 Byte 8 Bits: b String of binary digits are called bit strings. A bit string is interpreted as a binary number. b n b n-1 b 2 b 1 b a This bit string has the value: =

2 3 types: 1) char 2) unsigned char 3) signed char Each uses 1 Byte. Signed char -128 to 127 Unsigned char 0 to 255 Data Type int INTEGERS : Include the natural counting numbers and their negatives. INTEGRAL DATA TYPES: int short long unsigned 7 8 The magnitude of the number that an int variable can hold depends on? word size(bits) of the machine is machine dependent 2 Byte word ~ -32 K To +32K -2 15,, -3, -2, -1, 0, 1, 2, 3,, Integer overflow: Value too large for defined Storage Location. Typically program continues to run but incorrect results. 4 Byte word ~ -2 Billion To +2 Billion -2 31,. -3, -2, -1, 0, 1, 2, 3,, The programmer must strive at all times to avoid integer overflow. 10 Types short, long, unsigned short - used where conserving storage is a concern (usually 2 Bytes). -32 Thousand To +32 Thousand -2 15, ,, -3, -2, -1, 0, 1, 2, 3,, long - needed for larger integers (usually 4 bytes). -2 Billion To +2 Billion Unsigned - no sign bit, same number bytes as int. The range, u, of values: 0 u 2 wordsize -1 2 Byte word ~ 0 To + 64 Thousand 0, 1, 2, 3,, Byte word ~ 0 To + 4 Billion 0, 1, 2, 3,, , ,, -3, -2, -1, 0, 1, 2, 3,,

3 Suffix: u - 20u l 20l ul - 20ul (case not significant) IF no suffix with constant - system will choose the first of : int - long - unsigned long That can hold the value. 13 The Floating Types float double long double Suffixes for constants f or F float 3.7 F l or L long double 3.7 L Any unsuffixed floating constant is of type double (working type). 14 Notation: exponential or decimal Must have Exponent or Dec pt or Both e e e0 correct 0.0.e0 wrong Precision: The number of significant decimal digits that floating value carries. Range: Limits of largest & smallest possible values that can be in a variable of that type. Float: 4 Bytes - about 6 decimal places of accuracy- single precision. May not contain any blanks or special characters. Typical Storage: Float < Double 15 Double: 8 Bytes - about 15 decimal places of accuracy- double precision. 16 FLOAT: Internal Representation SEEEEEEEE mmmmm m Float: Precision: 6 significant digits. Range: to d 1 d 2 d 3 d 4 d 5 d 6 10 n DOUBLE: SEEEEEEEEEEE mmmmmmm m Implied mantissa of 1 is not stored. Double: Precision: 15 significant digits ( ) Range: to Sign bit (1 for neg-otherwise pos)

4 Note: 1. Not all Real numbers are exactly representable in binary memory. 2. Floating Arithmetic ops, unlike integer arithmetic, may not be exact. Compile-Time Operator sizeof Unary operator used to find the number of Bytes needed to store an object. sizeof(object) Object Data type int, float, Expression a + b 19 Array Structure Will cover later 20 sizeof(char) = 1 Assuming that integers are 4 bytes and doubles are 8 bytes. sizeof(short) sizeof(int) sizeof(long) sizeof(signed)=sizeof(unsigned)=sizeof(int) double f; printf("%d ",sizeof (f)); 8 printf(''%d", sizeof(int)); 4 sizeof(float) <= sizeof(double ) <= sizeof( long double) Conversions When constants and variables of different types are mixed in an, the compiler converts all operands to the type of the largest operand- Called Type Promotion. - First, all char and short values are automatically elevated to int. Called integral promotion. - int + int = int - short + short = int char ch; int i; float f; double d,result; result= (ch / i) + (f * d) (f + i); int double float - Arithmetic Conversion (See pg. 217) double

5 Casts Casts - Explicit conversions. (type) (float) i/2 If i is int: (float) i will change value to float, i is not changed. 25 Apply to an Expression: (float) ( c + 3) Cannot apply to an Assignment: (int) f = 3: illegal As an unary operator, a cast has the same precedence as any other unary operator. (float) i + 3 ( (float) i ) /* print i and i/2 with fractions */ int main(void) { int i; for(i=l; i<=100; ++i) printf(''%d //2 is: %f \n", i, (float) i /2); return 0; } 27 General forms: (int) char - (char) int - (int) float - (float) int - (double) float exp- ordinal value of char character with the ordinal value of int truncates the float converts int to float converts float to double 28 5

THE FUNDAMENTAL DATA TYPES

THE FUNDAMENTAL DATA TYPES THE FUNDAMENTAL DATA TYPES Declarations, Expressions, and Assignments Variables and constants are the objects that a prog. manipulates. All variables must be declared before they can be used. #include

More information

LESSON 5 FUNDAMENTAL DATA TYPES. char short int long unsigned char unsigned short unsigned unsigned long

LESSON 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 information

Chapter 3. Fundamental Data Types

Chapter 3. Fundamental Data Types Chapter 3. Fundamental Data Types Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr Variable Declaration

More information

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example

Number Systems. Binary Numbers. Appendix. Decimal notation represents numbers as powers of 10, for example Appendix F Number Systems Binary Numbers Decimal notation represents numbers as powers of 10, for example 1729 1 103 7 102 2 101 9 100 decimal = + + + There is no particular reason for the choice of 10,

More information

Chapter 7. Basic Types

Chapter 7. Basic Types Chapter 7 Basic Types Dr. D. J. Jackson Lecture 7-1 Basic Types C s basic (built-in) types: Integer types, including long integers, short integers, and unsigned integers Floating types (float, double,

More information

Introduction to C. Systems Programming Concepts

Introduction to C. Systems Programming Concepts Introduction to C Systems Programming Concepts Introduction to C A simple C Program Variable Declarations printf ( ) Compiling and Running a C Program Sizeof Program #include What is True in C? if example

More information

Computer System and programming in C

Computer System and programming in C 1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign

More information

Programming in C++ 6. Floating point data types

Programming 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 information

Have the same meaning as variables in algebra Single alphabetic character Each variable needs an identifier that distinguishes it from the others a =

Have the same meaning as variables in algebra Single alphabetic character Each variable needs an identifier that distinguishes it from the others a = Morteza Noferesti Have the same meaning as variables in algebra Single alphabetic character Each variable needs an identifier that distinguishes it from the others a = 5 x = a + b valid identifier in C

More information

First of all, it is a variable, just like other variables you studied

First of all, it is a variable, just like other variables you studied Pointers: Basics What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the address (rather than the value)

More information

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University

Fundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler

More information

These are reserved words of the C language. For example int, float, if, else, for, while etc.

These are reserved words of the C language. For example int, float, if, else, for, while etc. Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.

More information

int main(void) { int a, b, c; /* declaration */

int main(void) { int a, b, c; /* declaration */ &KDSWHULQ$%& #include int main(void) { int a, b, c; /* declaration */ float x, y=3.3, z=-7.7; /* declaration with initialization */ printf("input two integers: "); /* function call */ scanf("%d%d",

More information

CHAPTER 3 Expressions, Functions, Output

CHAPTER 3 Expressions, Functions, Output CHAPTER 3 Expressions, Functions, Output More Data Types: Integral Number Types short, long, int (all represent integer values with no fractional part). Computer Representation of integer numbers - Number

More information

3. 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. 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 information

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

CS107, Lecture 3 Bits and Bytes; Bitwise Operators CS107, Lecture 3 Bits and Bytes; Bitwise Operators reading: Bryant & O Hallaron, Ch. 2.1 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution

More information

Data Types. Data Types. Integer Types. Signed Integers

Data Types. Data Types. Integer Types. Signed Integers Data Types Data Types Dr. TGI Fernando 1 2 The fundamental building blocks of any programming language. What is a data type? A data type is a set of values and a set of operations define on these values.

More information

ISA 563 : Fundamentals of Systems Programming

ISA 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 information

Basic Types and Formatted I/O

Basic Types and Formatted I/O Basic Types and Formatted I/O C Variables Names (1) Variable Names Names may contain letters, digits and underscores The first character must be a letter or an underscore. the underscore can be used but

More information

Programming in C++ 5. Integral data types

Programming 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 information

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Review: 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 information

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

10.1. Unit 10. Signed Representation Systems Binary Arithmetic 0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system

More information

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O

Overview of C. Basic Data Types Constants Variables Identifiers Keywords Basic I/O Overview of C Basic Data Types Constants Variables Identifiers Keywords Basic I/O NOTE: There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators.

More information

1.3b Type Conversion

1.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 information

Work relative to other classes

Work 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 information

Data Type Fall 2014 Jinkyu Jeong

Data Type Fall 2014 Jinkyu Jeong Data Type Fall 2014 Jinkyu Jeong (jinkyu@skku.edu) 1 Syntax Rules Recap. keywords break double if sizeof void case else int static... Identifiers not#me scanf 123th printf _id so_am_i gedd007 Constants

More information

Operators and Expressions:

Operators and Expressions: Operators and Expressions: Operators and expression using numeric and relational operators, mixed operands, type conversion, logical operators, bit operations, assignment operator, operator precedence

More information

Internal representation. Bitwise operators

Internal representation. Bitwise operators Computer Programming Internal representation. Bitwise operators Marius Minea marius@cs.upt.ro 24 October 2016 Ideal math and C are not the same! In mathematics: integers Z and reals R have unbounded values

More information

Internal representation. Bitwise operators

Internal representation. Bitwise operators Computer Programming Internal representation. Bitwise operators Marius Minea marius@cs.upt.ro 23 October 2017 Ideal math and C are not the same! In mathematics: integers Z and reals R have unbounded values

More information

COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization. Data Representation COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

More information

Expressions and Casting

Expressions and Casting Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence

More information

More Programming Constructs -- Introduction

More 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 information

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed CS 150 Introduction to Computer Science I Data Types Today Last we covered o main function o cout object o How data that is used by a program can be declared and stored Today we will o Investigate the

More information

Internal representation. Bitwise operators

Internal representation. Bitwise operators Computer Programming Internal representation. Bitwise operators Marius Minea marius@cs.upt.ro 26 October 2015 Ideal math and C are not the same! In mathematics: integers Z and reals R have unbounded values

More information

Number Systems. Both numbers are positive

Number Systems. Both numbers are positive Number Systems Range of Numbers and Overflow When arithmetic operation such as Addition, Subtraction, Multiplication and Division are performed on numbers the results generated may exceed the range of

More information

Variables and Constants

Variables and Constants HOUR 3 Variables and Constants Programs need a way to store the data they use. Variables and constants offer various ways to work with numbers and other values. In this hour you learn: How to declare and

More information

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

CS107, Lecture 3 Bits and Bytes; Bitwise Operators CS107, Lecture 3 Bits and Bytes; Bitwise Operators reading: Bryant & O Hallaron, Ch. 2.1 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution

More information

Computer Systems Programming. Practice Midterm. Name:

Computer Systems Programming. Practice Midterm. Name: Computer Systems Programming Practice Midterm Name: 1. (4 pts) (K&R Ch 1-4) What is the output of the following C code? main() { int i = 6; int j = -35; printf( %d %d\n,i++, ++j); i = i >

More information

World Inside a Computer is Binary

World Inside a Computer is Binary C Programming 1 Representation of int data World Inside a Computer is Binary C Programming 2 Decimal Number System Basic symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Radix-10 positional number system. The radix

More information

Fundamentals of Programming

Fundamentals 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 information

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee C Language Part 1 (Minor modifications by the instructor) References C for Python Programmers, by Carl Burch, 2011. http://www.toves.org/books/cpy/ The C Programming Language. 2nd ed., Kernighan, Brian,

More information

Fundamental of Programming (C)

Fundamental 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 information

On a 64-bit CPU. Size/Range vary by CPU model and Word size.

On a 64-bit CPU. Size/Range vary by CPU model and Word size. On a 64-bit 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 information

CSE 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 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 information

Arithmetic Operators. Portability: Printing Numbers

Arithmetic 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 information

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013 Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence

More information

INTRODUCTION TO COMPUTER SCIENCE - LAB

INTRODUCTION TO COMPUTER SCIENCE - LAB LAB # O2: OPERATORS AND CONDITIONAL STATEMENT Assignment operator (=) The assignment operator assigns a value to a variable. X=5; Expression y = 2 + x; Increment and decrement (++, --) suffix X++ X-- prefix

More information

Exercise: Using Numbers

Exercise: Using Numbers Exercise: Using Numbers Problem: You are a spy going into an evil party to find the super-secret code phrase (made up of letters and spaces), which you will immediately send via text message to your team

More information

Pointers (2) Applications

Pointers (2) Applications Pointers (2) Applications December 9, 2017 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported license. 0.1 const qaulifier t1.c #include #include

More information

Operators 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 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 information

LECTURE 3 C++ Basics Part 2

LECTURE 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 information

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng. CS 265 Computer Architecture Wei Lu, Ph.D., P.Eng. 1 Part 1: Data Representation Our goal: revisit and re-establish fundamental of mathematics for the computer architecture course Overview: what are bits

More information

Main Memory Organization

Main Memory Organization Main Memory Organization Bit Smallest piece of memory Stands for binary digit Has values 0 (off) or 1 (on) Byte Is 8 consecu>ve bits Word Usually 4 consecu>ve bytes Has an address 8 bits 0 1 1 0 0 1 1

More information

CS113: 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 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 information

Floating Point Numbers

Floating Point Numbers Floating Point Numbers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran

More information

Floating Point Numbers

Floating Point Numbers Floating Point Numbers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Fractions in Binary Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU)

More information

Outline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands

Outline. Performing Computations. Outline (cont) Expressions in C. Some Expression Formats. Types for Operands Performing Computations C provides operators that can be applied to calculate expressions: tax is 8.5% of the total sale expression: tax = 0.085 * totalsale Need to specify what operations are legal, how

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

Computer Organization & Systems Exam I Example Questions

Computer Organization & Systems Exam I Example Questions Computer Organization & Systems Exam I Example Questions 1. Pointer Question. Write a function char *circle(char *str) that receives a character pointer (which points to an array that is in standard C

More information

CS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II

CS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II CS107 Handout 13 Spring 2008 April 18, 2008 Computer Architecture: Take II Example: Simple variables Handout written by Julie Zelenski and Nick Parlante A variable is a location in memory. When a variable

More information

CSC 1107: Structured Programming

CSC 1107: Structured Programming CSC 1107: Structured Programming J. Kizito Makerere University e-mail: www: materials: e-learning environment: office: alt. office: jkizito@cis.mak.ac.ug http://serval.ug/~jona http://serval.ug/~jona/materials/csc1107

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

More information

CS101 Lecture 04: Binary Arithmetic

CS101 Lecture 04: Binary Arithmetic CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary

More information

ECE232: Hardware Organization and Design

ECE232: Hardware Organization and Design ECE232: Hardware Organization and Design Lecture 11: Floating Point & Floating Point Addition Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Last time: Single Precision Format

More information

Lecture 02 C FUNDAMENTALS

Lecture 02 C FUNDAMENTALS Lecture 02 C FUNDAMENTALS 1 Keywords C Fundamentals auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void

More information

BSM540 Basics of C Language

BSM540 Basics of C Language BSM540 Basics of C Language Chapter 3: Data and C Prof. Manar Mohaisen Department of EEC Engineering Review of the Precedent Lecture Explained the structure of a simple C program Introduced comments in

More information

1 class Lecture2 { 2 3 "Elementray Programming" / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch.

1 class Lecture2 { 2 3 Elementray Programming / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 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 41 / 68 Example Given the radius

More information

5.Coding for 64-Bit Programs

5.Coding for 64-Bit Programs Chapter 5 5.Coding for 64-Bit Programs This chapter provides information about ways to write/update your code so that you can take advantage of the Silicon Graphics implementation of the IRIX 64-bit operating

More information

Data Representation Floating Point

Data Representation Floating Point Data Representation Floating Point CSCI 2400 / ECE 3217: Computer Architecture Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides via Jason Fritts Today: Floating Point Background:

More information

COP 3275: Chapter 07. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA

COP 3275: Chapter 07. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA COP 3275: Chapter 07 Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA Basic Types C s basic (built-in) types: Integer types, including long integers, short integers, and unsigned integers

More information

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754 Floating Point Puzzles Topics Lecture 3B Floating Point IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties For each of the following C expressions, either: Argue that

More information

UNIT 3 OPERATORS. [Marks- 12]

UNIT 3 OPERATORS. [Marks- 12] 1 UNIT 3 OPERATORS [Marks- 12] SYLLABUS 2 INTRODUCTION C supports a rich set of operators such as +, -, *,,

More information

Applied C and C++ Programming

Applied C and C++ Programming Applied C and C++ Programming Alice E. Fischer David W. Eggert University of New Haven Michael J. Fischer Yale University August 2018 Copyright c 2018 by Alice E. Fischer, David W. Eggert, and Michael

More information

As stated earlier, the declaration

As stated earlier, the declaration The int data type As stated earlier, the declaration int a; is an instruction to the compiler to reserve a certain amount of memory to hold the values of the variable a. How much memory? Two bytes (usually,

More information

Primitive 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: 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 information

UNIT- 3 Introduction to C++

UNIT- 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 information

Programming for Engineers Iteration

Programming for Engineers Iteration Programming for Engineers Iteration ICEN 200 Spring 2018 Prof. Dola Saha 1 Data type conversions Grade average example,-./0 class average = 23450-67 893/0298 Grade and number of students can be integers

More information

Informatics Ingeniería en Electrónica y Automática Industrial

Informatics Ingeniería en Electrónica y Automática Industrial Informatics Ingeniería en Electrónica y Automática Industrial Operators and expressions in C Operators and expressions in C Numerical expressions and operators Arithmetical operators Relational and logical

More information

Question 4: a. We want to store a binary encoding of the 150 original Pokemon. How many bits do we need to use?

Question 4: a. We want to store a binary encoding of the 150 original Pokemon. How many bits do we need to use? Question 4: a. We want to store a binary encoding of the 150 original Pokemon. How many bits do we need to use? b. What is the encoding for Pikachu (#25)? Question 2: Flippin Fo Fun (10 points, 14 minutes)

More information

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2)

ECE2049: Embedded Computing in Engineering Design C Term Spring Lecture #3: Of Integers and Endians (pt. 2) ECE2049: Embedded Computing in Engineering Design C Term Spring 2018 Lecture #3: Of Integers and Endians (pt. 2) Reading for Today: Davies Ch 2, MSP430 User's Guide Ch 6.1, 6.3 Reading for Next Class:

More information

ESc101 : Fundamental of Computing

ESc101 : Fundamental of Computing ESc101 : Fundamental of Computing I Semester 2008-09 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 information

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That 1. Introduction You have seen situations in which the way numbers are stored in a computer affects a program. For example, in the

More information

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring: ECE 120 Midterm 1 HKN Review Session Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location: Your Room on Compass What to bring: icard, pens/pencils, Cheat sheet (Handwritten) Overview of Review Binary IEEE

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Disclaimer The slides are prepared from various sources. The purpose of the slides is for academic use only Operators in C C supports a rich set of operators. Operators

More information

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014 Problem 1 (4 parts, 21 points) Encoders and Pass Gates Part A (8 points) Suppose the circuit below has the following input priority: I 1 > I 3 > I 0 > I 2. Complete the truth table by filling in the input

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT 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 information

CS16 Exam #1 7/17/ Minutes 100 Points total

CS16 Exam #1 7/17/ Minutes 100 Points total CS16 Exam #1 7/17/2012 75 Minutes 100 Points total Name: 1. (10 pts) Write the definition of a C function that takes two integers `a` and `b` as input parameters. The function returns an integer holding

More information

A Fast Review of C Essentials Part I

A Fast Review of C Essentials Part I A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types

More information

CS101 Introduction to computing Floating Point Numbers

CS101 Introduction to computing Floating Point Numbers CS101 Introduction to computing Floating Point Numbers A. Sahu and S. V.Rao Dept of Comp. Sc. & Engg. Indian Institute of Technology Guwahati 1 Outline Need to floating point number Number representation

More information

Floating Point Arithmetic

Floating Point Arithmetic Floating Point Arithmetic Computer Systems, Section 2.4 Abstraction Anything that is not an integer can be thought of as . e.g. 391.1356 Or can be thought of as + /

More information

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion

Agenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,

More information

Data Representation Floating Point

Data Representation Floating Point Data Representation Floating Point CSCI 2400 / ECE 3217: Computer Architecture Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides via Jason Fritts Today: Floating Point Background:

More information

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz

CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,

More information

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation Chapter 2 Float Point Arithmetic Topics IEEE Floating Point Standard Fractional Binary Numbers Rounding Floating Point Operations Mathematical properties Real Numbers in Decimal Notation Representation

More information

Java Notes. 10th ICSE. Saravanan Ganesh

Java 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 information

CS429: Computer Organization and Architecture

CS429: Computer Organization and Architecture CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: September 18, 2017 at 12:48 CS429 Slideset 4: 1 Topics of this Slideset

More information

Basics of Programming

Basics of Programming Unit 2 Basics of Programming Problem Analysis When we are going to develop any solution to the problem, we must fully understand the nature of the problem and what we want the program to do. Without the

More information

Engineering Computing I

Engineering Computing I Engineering Computing I Types, Operators, and Expressions Types Operators Expressions 2 1 2.1 Variable Names Names are made up of letters and digits The first character must be a letter The underscore

More information

Up next. Midterm. Today s lecture. To follow

Up next. Midterm. Today s lecture. To follow Up next Midterm Next Friday in class Exams page on web site has info + practice problems Excited for you to rock the exams like you have been the assignments! Today s lecture Back to numbers, bits, data

More information

FLOATING POINT NUMBERS

FLOATING POINT NUMBERS Exponential Notation FLOATING POINT NUMBERS Englander Ch. 5 The following are equivalent representations of 1,234 123,400.0 x 10-2 12,340.0 x 10-1 1,234.0 x 10 0 123.4 x 10 1 12.34 x 10 2 1.234 x 10 3

More information