Basic Types CGS 3460, Lecture 19 Feb 22, 2006 Hen-I Yang.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

Kernighan/Ritchie: Kelley/Pohl:
15213 Recitation Fall 2014 Section A, 8 th September Vinay Bhat.
Sizes of simple data types sizeof(char) = 1 size(short) = 2 sizeof(int) = 4 size(long) = 8 sizeof(char) = 1 size(short) = 2 sizeof(int) = 2 size(long)
Differences between Java and C CS-2303, C-Term Differences between Java and C CS-2303, System Programming Concepts (Slides include materials from.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Introduction to Computers and Programming Lecture 15: Arrays Professor: Evan Korth New York University.
Constants Variables change, constants don't final = ; final double PI = ; … area = radius * radius * PI; see Liang, p. 32 for full code.
Please pick up an attendance question and submit in 5 minutes CS 1003 Lecture #3 Sept 12, 2006 Knarig Arabshian.
Assignment Operators =, +=, *= A += B means (A+B) --->A or A = (A+B) Similarly true for -=, *=, /=, and %=. The basic rule is from right to left. Never.
CS1061 C Programming Lecture 4: Indentifiers and Integers A.O’Riordan, 2004.
CS150 Introduction to Computer Science 1
COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez
1 COMP 2130 Introduction to Computer Systems Computing Science Thompson Rivers University.
Arrays (2) CGS 3460, Lecture 23 Mar 3, 2006 Hen-I Yang.
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
C Tokens Identifiers Keywords Constants Operators Special symbols.
C Programming n General Information on C n Data Types n Arithmetic Operators n Relational Operators n if, if-else, for, while by Kulapan Waranyuwat.
Number Representation
Week 2 - Wednesday.  What did we talk about last time?  C compilation model  Lab 1.
CISC105 – General Computer Science Class 9 – 07/03/2006.
Spring 2005, Gülcihan Özdemir Dağ Lecture 7, Page 1 BIL104E: Introduction to Scientific and Engineering Computing, Spring Lecture 7 Outline 7. 1.
1 Exam / Homework Exam 1 in Class 10 –Open book / open notes HW3 due next class HW4 will be on-line soon. Finishing Chapter 2 of K&R. We will go through.
Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft RAM Allocation Chapter 3.
Iteration Statements CGS 3460, Lecture 17 Feb 17, 2006 Hen-I Yang.
Iteration Statements CGS 3460, Lecture 18 Feb 20, 2006 Hen-I Yang.
CS115 FALL Senem KUMOVA-METİN1 The Fundamental Data Types CHAPTER 3.
1 The Design of C: A Rational Reconstruction: Part 1 Jennifer Rexford.
Chapter 4 Literals, Variables and Constants. #Page2 4.1 Literals Any numeric literal starting with 0x specifies that the following is a hexadecimal value.
Chapter 7 C supports two fundamentally different kinds of numeric types: (a) integer types - whole numbers (1) signed (2) unsigned (b) floating types –
Lecture 3 Introduction to Computer Programming CUIT A.M. Gamundani Presentation Layout from Lecture 1 Background.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Variables Symbol representing a place to store information
Summary CGS 3460, Lecture 43 April 26, 2006 Hen-I Yang.
Linked List (II) CGS 3460, Lecture 37 Apr 12, 2006 Hen-I Yang.
1.2 Primitive Data Types and Variables
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.
0 Chap.2. Types, Operators, and Expressions 2.1Variable Names 2.2Data Types and Sizes 2.3Constants 2.4Declarations 2.5Arithmetic Operators 2.6Relational.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Online Judge System Tom Chao Zhou CSC2100B Data Structures Tutorial 2.
Gator Engineering Project 1 Grades released Re-grading –Within one week –TA: Fardad, or office hours: MW 2:00 – 4:00 PM TA Huiyuan’s office hour.
LESSON 5 – Assignment Statements JAVA PROGRAMMING.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
7. BASIC TYPES. Systems of numeration Numeric Types C’s basic types include integer types and floating types. Integer types can be either signed or unsigned.
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
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.
Object Oriented Programming Lecture 2: BallWorld.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Chapter 3 Structured Program Development in C Part II C How to Program, 8/e, GE © 2016 Pearson Education, Ltd. All rights reserved.1.
Course Contents KIIT UNIVERSITY Sr # Major and Detailed Coverage Area
CSE 220 – C Programming Bitwise Operators.
EPSII 59:006 Spring 2004.
Variable Symbol represents a place to store information
Fundamental Data Types
Roller Coaster Design Project
Conversions of the type of the value of an expression
CS1S467 GUI Programming Lecture 3 Variables 2.
Embedded Programming in C
Lesson 26 Miscellaneous Topics
Differences between Java and C
Fundamental Data Types
B065: PROGRAMMING Variables 1.
Homework Finishing Chapter 2 of K&R. We will go through Chapter 3 very quickly. Not a lot is new. Questions?
Variables in C Topics Naming Variables Declaring Variables
C Language B. DHIVYA 17PCA140 II MCA.
Variables and Constants
Presentation transcript:

Basic Types CGS 3460, Lecture 19 Feb 22, 2006 Hen-I Yang

Previously… goto, null statement Road map to more advanced topics.

Agenda Homework 3 Types int float

A Glimpse of Quiz 2 What is in Quiz 2?  Everything related to Homework2  Everything in the textbook up to Section 5-2  Everything listed on the “topics” page up to Feb 10 About Quiz 2  Bring Gator 1 ID  20 minutes starting 9:35 am sharp  No electronic device of any sort is allowed  To have homework 2 counted toward your grade, you have to take quiz 2.  Lecture will continue after the completion of the quiz

Homework 3: Prologue Professor Dumbledore has just accepted to join UF as a visiting professor for one year. As the house/apartment rental season fast approaching, he is trying to find the best housing available for his family in the Gainesville area as soon as possible.

Homework 3: Problem 1 Realty Consultant Problem 3.1 Pick best house out of five

Homework 3 (II): Problem 2 Draw a Map Find Optimal House Location

Homework 3 (III) Hints How do we calculate absolute values?  A function called abs() [NOT ALLOWED]  if (x > y) z = x – y; else z = y – x;  z = (x > y) ? x – y : y – x; How do we work through two dimension grids?  Nested loops  for (x = 1; x <=25; x++) { for (y = 1; y <= 25; y++) { // You may need to check for special locations printf(“.”); } printf(“\n”); }

STAGE 3 We are moving on the more advance materials now. Types: What are they, why are they important Arrays: Tired of declaring 10 variables for 10 entries of the same thing? Functions: How do we pack code segments into something more meaningful? Pointers: Let the fun begins.

Types Every data of variable is stored in the form of binary. Compiler/CPU handles the variables based on what the programmer makes of it Compiler does “type conversion” automatically based on certain rules Programmers can explicitly make data another type that it was not meant to be (casting)

Types (II) Three basic types  int  float  char The range and precision of value, or even presentation of the value of a variable can hold is machine dependent. C language specification is flexible in these “details”

int int, short, long signed, unsigned Integers are stored as binary, sometimes with bit sign You can specify different “sizes” of int You can also specify signed and unsigned flavor of int beware of the max/min of int, otherwise it might overflow The max/min depends on whether the machine is 16 or 32 bits, also depends on signed/unsigned By default, int are signed (unsigned has be to specifically declared) If a 16-bit integer, with maximum allowed value is barely enough, then use long int Long/unsigned/int can be permuted (order does not matter, int can be omitted)

Int (II) The values are machine dependent However, the relative size of short, int and long always remain Range short <= Range int <= Range long Usually, if an integer is expected to exceed 32767, we use long for portability, but long may operate more slowly because there are more bits to operate on Revisit: Decimal, Octal , Hexadecimal 0xf 0xff 0xFF 0XFF When specified as a constant expression  15L, 0377L, 0x7fffL (long)  15U, 0377U, 0x7fffU (unsigned) More conversion specifications  %u, %o, %x, %hd (short), %ld (long)  %d only work for int

Summary Quiz 2 Homework 3 Type int

Before you go Read Chapter 7. Exercise: 7.3, 7.4 Quiz 2 on Feb 24, Friday at 9:35 am, remember to bring Gator 1 ID card Homework 2 late submission ends tomorrow night (Feb 23, Thursday at 11:59 pm)