CSE 1320 INTERMEDIATE PROGRAMMING - OVERVIEW AND DATA TYPES

Similar documents
CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

Basic data types. Building blocks of computation

Chapter 3. Fundamental Data Types

Final Labs and Tutors

Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation

Work relative to other classes

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

Data Type Fall 2014 Jinkyu Jeong

M1 Computers and Data

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

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

UNIT 7A Data Representation: Numbers and Text. Digital Data

Computer Systems Programming. Practice Midterm. Name:

Syntax and Variables

Midterm Exam Review Slides

MACHINE LEVEL REPRESENTATION OF DATA

Chapter 4: Computer Codes. In this chapter you will learn about:

Digital Computers and Machine Representation of Data

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

Programming Language Basics

Chapter 7. Basic Types

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

The type of all data used in a C (or C++) program must be specified

Computer System and programming in C

C-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga

COMP2611: Computer Organization. Data Representation

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

BSM540 Basics of C Language

THE FUNDAMENTAL DATA TYPES

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

Lecture 3. Review. CS 141 Lecture 3 By Ziad Kobti -Control Structures Examples -Built-in functions. Conditions: Loops: if( ) / else switch

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

CIS 2107 Computer Systems and Low-Level Programming Fall 2011 Midterm

Programming and Data Structure

Chapter 4: Data Representations

Chapter 11 Introduction to Programming in C

Basic Elements of C. Staff Incharge: S.Sasirekha

The Building Blocks: Binary Numbers, Boolean Logic, and Gates. Purpose of Chapter. External Representation of Information.

DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Experimental Methods I

Lecture 03 Bits, Bytes and Data Types

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

As stated earlier, the declaration

Programming in C++ 6. Floating point data types

COMP2121: Microprocessors and Interfacing. Number Systems

Chapter 11 Introduction to Programming in C

Introduction to Informatics

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

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

printf( Please enter another number: ); scanf( %d, &num2);

Number Systems II MA1S1. Tristan McLoughlin. November 30, 2013

IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

Number System (1A) Young Won Lim 7/7/10

공학프로그래밍언어 (PROGRAMMING LANGUAGE FOR ENGINEERS) -VARIABLE AND DATA TYPES- SPRING 2015, SEON-JU AHN, CNU EE

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

The type of all data used in a C++ program must be specified

Chapter 11 Introduction to Programming in C

10.1. Unit 10. Signed Representation Systems Binary Arithmetic

9/23/15. Agenda. Goals of this Lecture. For Your Amusement. Number Systems and Number Representation. The Binary Number System

A Fast Review of C Essentials Part I

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

C Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering.

Fundamentals of Programming Session 2

Datatypes, Variables, and Operations

.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..

CS Programming In C

C Formatted IO. Day16.C. Young W. Lim. December 9, 2017

Chapter 11 Introduction to Programming in C

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

UNIT-I Input/ Output functions and other library functions

CSE 12 Spring 2016 Week One, Lecture Two

Arithmetic Expressions in C

211: Computer Architecture Summer 2016

Homework 1 graded and returned in class today. Solutions posted online. Request regrades by next class period. Question 10 treated as extra credit

ECE264 Fall 2013 Exam 3, November 20, 2013

1/25/2018. ECE 220: Computer Systems & Programming. Write Output Using printf. Use Backslash to Include Special ASCII Characters

Gabriel Hugh Elkaim Spring CMPE 013/L: C Programming. CMPE 013/L: C Programming

Data Types and Computer Storage Arrays and Pointers. K&R, chapter 5

Binghamton University. CS-211 Fall Syntax. What the Compiler needs to understand your program

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

The Design of C: A Rational Reconstruction

Approximately a Test II CPSC 206

Chapter 11 Introduction to Programming in C

Princeton University. Computer Science 217: Introduction to Programming Systems. Data Types in C

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

The Design of C: A Rational Reconstruction"

CPS 104 Computer Organization and Programming Lecture-2 : Data representations,

CS 261 Fall Floating-Point Numbers. Mike Lam, Professor.

Home brewed code for conversion of single precision float value to string

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

CYSE 411/AIT681 Secure Software Engineering Topic #12. Secure Coding: Formatted Output

2/9/18. CYSE 411/AIT681 Secure Software Engineering. Readings. Secure Coding. This lecture: String management Pointer Subterfuge

CS-211 Fall 2017 Test 1 Version Practice For Test on Oct. 2, Name:

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 4

SU2017. LAB 1 (May 4/9) Introduction to C, Function Declaration vs. Definition, Basic I/O (scanf/printf, getchar/putchar)

9/5/2018. Overview. The C Programming Language. Transitioning to C from Python. Why C? Hello, world! Programming in C

Princeton University Computer Science 217: Introduction to Programming Systems. Goals of this Lecture. Number Systems and Number Representation

Fundamental Data Types

Transcription:

CSE 1320 INTERMEDIATE PROGRAMMING - OVERVIEW AND DATA TYPES Mingon Kang The University of Texas at Arlington C History ANSI C, also known C89(ANSI X3.159-1989) and C90 (ISO/IEC 9899:1990) ANSI: American National Standards Institute ISO: International Organization for Standardization C95 (ISO/IEC 9899/AMD1:1995) Supports multi byte/wide character char sets C99 (ISO/IEC 9899:1999) One-line comments Intermingled variable declarations C11(ISO/IEC 9899:2011) Support Multi-threading Support Unicode (e.g., UTF-8) 1

Overview of Source code Components Comment Library declaration Variables Functions int main(void): a program starts from here User-defined functions C standard library provides very fundamental functions See overview.c in the course web 2

Comment Starts with /* symbol and ends with */ Can be anywhere in the source code A compiler ignores the block /* comment goes here */ // comment goes here This is not correct in C89 Or /* Author: Bill Gates * Purpose: To show a comment that spans multiple lines * Created on Aug. 2014 */ Library declaration Declare libraries that need to load in the program C standard library User-defined library #include <library_name.h> Or #include library_name.h 3

C standard Library Specified in the ANSI C standard Provides macros, type definition, and functions for string handling, mathematical computation, input/output processing, memory allocation, and etc. C standard Library Name <stdio.h> <math.h> <stdlib.h> <string.h> <time.h> Description Defines core input and output functions Defines common mathematical functions. Defines numeric conversion functions, pseudo-random numbers generation functions, memory allocation, process control functions Defines string handling functions. Defines date and time handling functions See http://www.tutorialspoint.com/c_standard_library/ 4

Functions Main() int main(void) int main(int argc, char **argv) User-defined function Functions that the C standard library provides E.g., printf: print formatted data to standard output Variables A name used to refer to a certain location in memory C programming requires that variables must be declared with the variable type int: an integer, typically reflecting the natural size of integers on the host machine char: a single byte, capable of holding one character float: single-precision floating point double: double-precision floating point Data Type Ranges: http://msdn.microsoft.com/en-us/library/s3f49ktz.aspx 5

Variables Data Types in C short (unsigned short) int (unsigned int) long (unsigned long) char float double Fundamentals of Computer Systems Bit: zero or one Morse Code, Punched Card, Electrical Switch, Two distinct Voltage or current levels 1 Byte = 8 bits historically for a single character A unit to access a memory Data can be accessed 8 bits or multiples of 8 bits at a time 16 bit vs 32 bits vs 64 bits computers? Processor registers (small amount of storage in a CPU) Data, Address, General purpose, Conditional, and so on.. 6

Character (1byte) ASCII code (American Standard Code for Information Interchange) DEC OCT HEX BIN Symbol HTML Number HTML Name Description 32 040 20 00100000 Space 33 041 21 00100001!! Exclamation mark 35 043 23 00100011 # # Number 36 044 24 00100100 $ $ Dollar 37 045 25 00100101 % % Procenttecke n ASCII code Table: http://www.ascii-code.com/ 48 060 30 00110000 0 0 Zero 49 061 31 00110001 1 1 One 50 062 32 00110010 2 2 Two 51 063 33 00110011 3 3 Three 65 101 41 01000001 A A 66 102 42 01000010 B B 97 141 61 01100001 a &#97 98 142 62 01100010 b b Uppercase A Uppercase B Lowercase a Lowercase b 7

Integer 2 bytes in 16 bits systems 4 bytes in 32/64 bits systems Unsigned integer: 0 ~ 2 n 1 Signed integer (two's complement): 2 n 1 ~ 2 n 1 1 Integer: http://en.wikipedia.org/wiki/integer_(computer_science) Two s complement: http://en.wikipedia.org/wiki/two%27s_complement Float: single-precision floating-point format A bit for sign (0: positive, 1: negative) 8 bits for exponent 23 bits for fraction http://en.wikipedia.org/wiki/single-precision_floating-point_format 8

Double: double-precision floating-point format http://en.wikipedia.org/wiki/double-precision_floating-point_format Print formatted data printf function from <stdio.h> int printf (char * format, ); Specified character at format d : signed decimal integer u : unsigned decimal integer f : decimal floating point e : scientific notation (e.g., 3.8254e+2) c : character s : string of characters http://www.cplusplus.com/reference/cstdio/printf/ 9