# Types, Variables, and Constants

Size: px
Start display at page:

Transcription

1 , Variables, and Constants

2 What is a Type The space in which a value is defined Space All possible allowed values All defined operations Integer Space whole numbers +, -, x No divide 2 tj

3 Why Types No room for confusion in a computer Must get the same answer every time All data must be stored into memory somewhere Program Memory Data Memory Memory used to be expensive Minimize the amount needed 3 tj

4 C Types Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 4 tj

5 C Types - void No values No defined operations Used when we want to indicate that nothing is here Examples MyFunction(void); // call a function with no input parameters void YourFunction(int val){ // indicate that a function returns nothing 5 tj

6 C Types - bool - boolean 2 values true, false Logical operations and (&&), or ( ), not (!) Examples bool in1, in2, in3; in1 && in2; // in1 AND in2 // declare 3 variables of type bool in3 =!(in1 in2); // in3 = in1 NOR in2 6 tj

7 C Types char - character ASCII values a,b,c,1,2,3,\$,%,*, English language characters Unicode millions of values Stored in the computer as integers Same operations as integers Become characters when visualized Require a single quote Examples char initial1 = t ; char initial2 = j ; printf( %c%c, initial1, initial2); // print - tj printf( %c, (initial1 - initial2) ); // print (line feed) // = 10 linefeed 7 tj

8 NULL no character numbers add 0x30 upper and lower case differ by hex 0x20 8 tj

9 C Types int - integer Values are system dependent integers only 1, 2, 4, 8 bytes short int, int, long int, long long int Operations Arithmetic operations +, -, *, / Comparison operations <, >, <=, >=, ==,!= Bitwise operations ~,, &, ^, <<, >> Examples int aa, bb, cc; aa + bb; // add aa to bb // declare 3 variables of type int 9 tj

10 C Types int - integer Special considerations with type int Range is defined and limited SIGNED and UNSIGNED variants bit unsigned 8 bit signed 16 bit unsigned 16 bit signed 10 tj

11 C Types int - integer Consider 3 16bit variables of type short int aa = 32,500 bb = 300 cc = 15,000 signed unsigned aa + bb = -32,736 32,800 aa/cc = 2 11 tj

12 C Types special integers A special set of integers are defined for embedded systems Designed to allow register/memory access Not system dependent #include <stdint.h> signed char unsigned char short unsigned short int unsigned long long unsigned long long int8_t; uint8_t; int16_t; uint16_t; int32_t; uint32_t; int64_t; uint64_t; 12 tj

13 C Types int - integer TI MSP432 Laptop 13 tj

14 C Types float real Values are system dependent SIGNED 4, 8 bytes 1,8,23-1,11,52 float, double, long double Operations Arithmetic operations +, -, *, / Comparison operations <, >, <=, >=, ==,!= Examples float aa, bb, cc; aa / bb; // aa divided by bb // declare 3 variables of type float 14 tj

15 C Types float imaginary Values are system dependent SIGNED 4, 8 bytes 1,8,23-1,11,52 float imaginary, double imaginary, long double imaginary Operations Arithmetic operations +, -, *, / Comparison operations <, >, <=, >=, ==,!= Not supported in many systems 15 tj

16 C Types float complex Values are system dependent SIGNED 4, 8 bytes 1,8,23-1,11,52 float complex, double complex, long double complex Operations Arithmetic operations +, -, *, / Comparison operations <, >, <=, >=, ==,!= Real and imaginary parts must be the same size 16 tj

17 C Types float - real Consider 3 variables of type float aa = 2.5 bb = cc = signed aa + bb = aa/cc = tj

18 Special Details Functions: sizeof(type) sizeof expression typeof(expression) Include <limits.h> <float.h> <stdint.h> SHRT_MIN SHRT_MAX USHRT_MAX INT_MIN INT_MAX Minimum value for an object of type short int Maximum value for an object of type short int Maximum value for an object of type unsigned short int Minimum value for an object of type int Maximum value for an object of type int defines max and min values for standard types 18 tj

19 Variables Variable Symbolic representation for a value - name Stored in memory (data) Can be modified during execution Since it requires space in memory it must have a type to tell the compiler how much space to reserve 19 tj

20 Variables Variable Declaration Specify the type and name for a variable Must be declared before it can be used int foo; float rate; char initial1; int var1, this, is, not, a, good, practice; int AccountBalance; int annual_interest_rate; ** Note: name length has no impact on compiled program size focus on readable code 20 tj

21 Variables Variable Initialization Variables are not initialized just by declaring them They do not automatically have a value of 0 They may well have garbage values Nothing stops you from using an un-initialized variable int foo = 23; int foo, boo = 23; int count; int foo = 23, boo = 23; count = 0; char = A ; float pie = ; 21 tj

22 Variables Variables and Memory int foo; char initial1 = t ; float rate = 2.5; char initial2; int boo = 255; reserved for foo has garbage in it initial 1 t hex 0x74 initial 2 - garbage unused - alignment binary 1.01 x sign 01 mantissa exponent boo x x x x x x x x x x x x x x x Memory Address 0x foo references this memory address 0x intial1 references this memory address 0x x C 0x tj

23 Constants Constant Symbolic representation for a value - name Stored in memory (program) Cannot be modified during execution Since it requires space in memory it must have a type to tell the compiler how much space to reserve 23 tj

24 Constants Constant Types Same as variable types + string Boolean true, false must include stdbool.h Character requires single quotes Integer can use a modifier to declare type 123 int 123L long int 123UL unsigned long int 24 tj

25 Constants Constant Types Real - Floating Point default is double can use a modifier to declare type 12.3 double 12.3F float 12.3L long double Complex - Floating Point default is double can use a modifier to declare type *I double complex 12.3F F*I float complex 12.3L L*I long double complex 25 tj

26 Constants Constant Types String Series of characters enclosed in double quotes this is a string constant Special considerations empty string \0 null character 26 tj

27 Constants Defining Constants Literal un-named constant a = b + 5; // 5 is a literal constant Defined Pre-processor constant #define INTEREST_RATE 0.01 Note ALL CAPS Memory Similar to a variable but cannot be changed const type identifier = value; const float interestrate = 0.01; Why bother with types? 27 tj

### Number Systems, Scalar Types, and Input and Output

Number Systems, Scalar Types, and Input and Output Outline: Binary, Octal, Hexadecimal, and Decimal Numbers Character Set Comments Declaration Data Types and Constants Integral Data Types Floating-Point

### Program Flow. Instructions and Memory. Why are these 16 bits? C code. Memory. a = b + c. Machine Code. Memory. Assembly Code.

Instructions and Memory C code Why are these 16 bits? a = b + c Assembly Code ldr r0, [sp, #4] ldr adds r1, [sp] r0, r0, r1 str r0, [sp, #8] Machine Code 09801 09900 01840 09002 Memory 0 0 0 0 0 0 0 1

### THE INTEGER DATA TYPES. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

THE INTEGER DATA TYPES STORAGE OF INTEGER TYPES IN MEMORY All data types are stored in binary in memory. The type that you give a value indicates to the machine what encoding to use to store the data in

### Types, Operators and Expressions

Types, Operators and Expressions EECS 2031 18 September 2017 1 Variable Names (2.1) l Combinations of letters, numbers, and underscore character ( _ ) that do not start with a number; are not a keyword.

### 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

### Programming. Elementary Concepts

Programming Elementary Concepts Summary } C Language Basic Concepts } Comments, Preprocessor, Main } Key Definitions } Datatypes } Variables } Constants } Operators } Conditional expressions } Type conversions

### Types, Operators and Expressions

Types, Operators and Expressions CSE 2031 Fall 2011 9/11/2011 5:24 PM 1 Variable Names (2.1) Combinations of letters, numbers, and underscore character ( _ ) that do not start with a number; are not a

### 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

### 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

### C Introduction. Comparison w/ Java, Memory Model, and Pointers

CS 261 Fall 2018 Mike Lam, Professor C Introduction Comparison w/ Java, Memory Model, and Pointers Please go to socrative.com on your phone or laptop, choose student login and join room LAMJMU The C Language

### File Handling in C. EECS 2031 Fall October 27, 2014

File Handling in C EECS 2031 Fall 2014 October 27, 2014 1 Reading from and writing to files in C l stdio.h contains several functions that allow us to read from and write to files l Their names typically

### 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.

### CS 261 Fall C Introduction. Variables, Memory Model, Pointers, and Debugging. Mike Lam, Professor

CS 261 Fall 2017 Mike Lam, Professor C Introduction Variables, Memory Model, Pointers, and Debugging The C Language Systems language originally developed for Unix Imperative, compiled language with static

### 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

### 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

### BASIC ELEMENTS OF A COMPUTER PROGRAM

BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators

### Type 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

### Number Representation 3/2/01 Lecture #

Number Representation 3/2/01 Lecture #11 16.070 How are numbers represented in a computer? Data come in two basic types! Numbers Whole/Integer (1, -3, 0) Natural, Positive (1, 2, 3) Real/Floating-point

### ECE2049 E17 Lecture 2: Data Representations & C Programming Basics

ECE2049 E17 Lecture 2: Data Representations & C Programming Basics Administrivia Lab 0 after class today! o Get your MSP430 board! Install instructions for CCS are on course website under Resources o You

### 1.1 Introduction to C Language. Department of CSE

1.1 Introduction to C Language 1 Department of CSE Objectives To understand the structure of a C-Language Program To write a minimal C program To introduce the include preprocessor command To be able to

### JAVA 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

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

The type of all data used in a C++ program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values There are

### Integer Data Types. Data Type. Data Types. int, short int, long int

Data Types Variables are classified according to their data type. The data type determines the kind of information that may be stored in the variable. A data type is a set of values. Generally two main

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

C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

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

공학프로그래밍언어 (PROGRAMMING LANGUAGE FOR ENGINEERS) -VARIABLE AND DATA TYPES- SPRING 2015, SEON-JU AHN, CNU EE COMMENT Comment Comments are usually added with the purpose of making the source code easier to

### 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

### 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

### Variables and literals

Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of

### XSEDE Scholars Program Introduction to C Programming. John Lockman III June 7 th, 2012

XSEDE Scholars Program Introduction to C Programming John Lockman III June 7 th, 2012 Homework 1 Problem 1 Find the error in the following code #include int main(){ } printf(find the error!\n");

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

Data Types and Computer Storage Arrays and Pointers K&R, chapter 5 Fundamental Data Types Most fundamental types are numeric (integer): - char - signed or unsigned - short int - signed or unsigned - int

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

The type of all data used in a C (or C++) program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values

### Declaration and Memory

Declaration and Memory With the declaration int width; the compiler will set aside a 4-byte (32-bit) block of memory (see right) The compiler has a symbol table, which will have an entry such as Identifier

### 11 'e' 'x' 'e' 'm' 'p' 'l' 'i' 'f' 'i' 'e' 'd' bool equal(const unsigned char pstr[], const char *cstr) {

This document contains the questions and solutions to the CS107 midterm given in Spring 2016 by instructors Julie Zelenski and Michael Chang. This was an 80-minute exam. Midterm questions Problem 1: C-strings

### 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,

### VARIABLES AND CONSTANTS

UNIT 3 Structure VARIABLES AND CONSTANTS Variables and Constants 3.0 Introduction 3.1 Objectives 3.2 Character Set 3.3 Identifiers and Keywords 3.3.1 Rules for Forming Identifiers 3.3.2 Keywords 3.4 Data

### Types. C Types. Floating Point. Derived. fractional part. no fractional part. Boolean Character Integer Real Imaginary Complex

Types C Types Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 2 tj Types C Types Derived Function Array Pointer Structure Union

### Room 3P16 Telephone: extension ~irjohnson/uqc146s1.html

UQC146S1 Introductory Image Processing in C Ian Johnson Room 3P16 Telephone: extension 3167 Email: Ian.Johnson@uwe.ac.uk http://www.csm.uwe.ac.uk/ ~irjohnson/uqc146s1.html Ian Johnson 1 UQC146S1 What is

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

CS5000: Foundations of Programming Mingon Kang, PhD Computer Science, Kennesaw State University Overview of Source Code Components Comments Library declaration Classes Functions Variables Comments Can

### Chapter 2: Overview of C++

Chapter 2: Overview of C++ Problem Solving, Abstraction, and Design using C++ 6e by Frank L. Friedman and Elliot B. Koffman C++ Background Introduced by Bjarne Stroustrup of AT&T s Bell Laboratories in

### PROGRAMMAZIONE I A.A. 2017/2018

PROGRAMMAZIONE I A.A. 2017/2018 TYPES TYPES Programs have to store and process different kinds of data, such as integers and floating-point numbers, in different ways. To this end, the compiler needs to

### Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

### 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

### Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School

Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions Mr. Dave Clausen La Cañada High School Vocabulary Variable- A variable holds data that can change while the program

### ESC101N Fundamentals of Computing

ESC101N Fundamentals of Computing Arnab Bhattacharya arnabb@iitk.ac.in Indian Institute of Technology, Kanpur http://www.iitk.ac.in/esc101/ 1 st semester, 2010-11 Tue, Wed, Fri 0800-0900 at L7 Arnab Bhattacharya

### Reserved Words and Identifiers

1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the

### LECTURE 02 INTRODUCTION TO C++

PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION

### 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

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

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

### INTRODUCTION 1 AND REVIEW

INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

### 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

### C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing

### Structures, Unions Alignment, Padding, Bit Fields Access, Initialization Compound Literals Opaque Structures Summary. Structures

Structures Proseminar C Grundlagen und Konzepte Michael Kuhn Research Group Scientific Computing Department of Informatics Faculty of Mathematics, Informatics und Natural Sciences University of Hamburg

### Java 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.)

### Motivation was to facilitate development of systems software, especially OS development.

A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

### 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

### Department of Computer Applications

Sheikh Ul Alam Memorial Degree College Mr. Ovass Shafi. (Assistant Professor) C Language An Overview (History of C) C programming languages is the only programming language which falls under the category

### Type Checking. Prof. James L. Frankel Harvard University

Type Checking Prof. James L. Frankel Harvard University Version of 7:10 PM 27-Feb-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. C Types C Types Type Category Type Category Type

### Lecture 2 Tao Wang 1

Lecture 2 Tao Wang 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common programming errors

### 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

### C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5

C++ Data Types Contents 1 Simple C++ Data Types 2 2 Quick Note About Representations 3 3 Numeric Types 4 3.1 Integers (whole numbers)............................................ 4 3.2 Decimal Numbers.................................................

### Unit 3. Constants and Expressions

1 Unit 3 Constants and Expressions 2 Review C Integer Data Types Integer Types (signed by default unsigned with optional leading keyword) C Type Bytes Bits Signed Range Unsigned Range [unsigned] char 1

### Topic 6: A Quick Intro To C

Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions

### CS242 COMPUTER PROGRAMMING

CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing

### CS1500 Algorithms and Data Structures for Engineering, FALL Virgil Pavlu, Jose Annunziato,

CS1500 Algorithms and Data Structures for Engineering, FALL 2012 Virgil Pavlu, vip@ccs.neu.edu Jose Annunziato, jannunzi@gmail.com Rohan Garg Morteza Dilgir Huadong Li cs1500hw@gmail.com http://www.ccs.neu.edu/home/vip/teach/cpp_eng/

### Language Reference Manual

ALACS Language Reference Manual Manager: Gabriel Lopez (gal2129) Language Guru: Gabriel Kramer-Garcia (glk2110) System Architect: Candace Johnson (crj2121) Tester: Terence Jacobs (tj2316) Table of Contents

### Chapter 2: Introduction to C++

Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++

### Embedded Systems - FS 2018

Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Lab 0 Date : 28.2.2018 Prelab Filling the gaps Goals of this Lab You are expected to be already familiar

### A flow chart is a graphical or symbolic representation of a process.

Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of

### Chapter 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, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley

### QUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:

QUIZ 1. Explain the meaning of the angle brackets in the declaration of v below: This is a template, used for generic programming! QUIZ 2. Why is the vector class called a container? 3. Explain how the

### Programming Language A

Programming Language A Takako Nemoto (JAIST) 26 November Takako Nemoto (JAIST) 26 November 1 / 12 Type char char is a datatype for characters. char express integers in certain region. For each ASCII character,

### CS300 Data Structrures (Fall 2014) Abstract data types (ADT s)

1 Abstract data types (ADT s) 2 Data Structures data factual information structure arrangement or relationship of elements The New Merriam-Webster Pocket Dictionary 3 Data Type A data type is defined by

### Motivation was to facilitate development of systems software, especially OS development.

A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

### 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,

### ANSI C Changes. Jonathan Hoyle Eastman Kodak 10/5/00

ANSI C Changes Jonathan Hoyle Eastman Kodak 10/5/00 ANSI C Changes Introduction Changes to C in conformance to C++ New additions to C friendly to C++ New additions to C unfriendly to C++ What has not changed

### Numeric Data Types in C

Numeric Data Types in C Kernighan & Ritchie - Chapter 2, Types, Operators, and Expressions (Binary) Integers - Counting char / unsigned char - a.k.a. signed char, unsigned char - Yes, you can do arithmetic

### EECS 388 C Introduction. Gary J. Minden August 29, 2016

EECS 388 C Introduction Gary J. Minden August 29, 2016 1 C Developed at AT&T Bell Laboratories in the early 1970s by Dennis Richie Intended as a systems programming language, that is used to write operating

### Data Representation and Storage. Some definitions (in C)

Data Representation and Storage Learning Objectives Define the following terms (with respect to C): Object Declaration Definition Alias Fundamental type Derived type Use pointer arithmetic correctly Explain

### 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

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

Standard 11 Lesson 9 Introduction to C++( Up to Operators) 2MARKS 1. Why C++ is called hybrid language? C++ supports both procedural and Object Oriented Programming paradigms. Thus, C++ is called as a

### Guide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below:

Q1. Explain the structure of a C program Structure of the C program is shown below: Preprocessor Directives Global Declarations Int main (void) Local Declarations Statements Other functions as required

### A First Program - Greeting.cpp

C++ Basics A First Program - Greeting.cpp Preprocessor directives Function named main() indicates start of program // Program: Display greetings #include using namespace std; int main() { cout

### Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

Basic C++ Overview C++ is a version of the older C programming language. This is a language that is used for a wide variety of applications and which has a mature base of compilers and libraries. C++ is

### TYPES, VALUES AND DECLARATIONS

COSC 2P90 TYPES, VALUES AND DECLARATIONS (c) S. Thompson, M. Winters 1 Names, References, Values & Types data items have a value and a type type determines set of operations variables Have an identifier

### Getting started with Java

Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

### CS 354 Midterm 1a, 33.33% Monday, October 9th, 2000 Solution

CS 354 Midterm 1a, 33.33% Monday, October 9th, 2000 Solution Parts Number of Questions Question Format Possible Points Score I 6 Short Answer 20 II 5 Multiple Choice 15 III 5 True or False 10 IV 6 Calculations

### 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

### Language Fundamentals Summary

Language Fundamentals Summary Claudia Niederée, Joachim W. Schmidt, Michael Skusa Software Systems Institute Object-oriented Analysis and Design 1999/2000 c.niederee@tu-harburg.de http://www.sts.tu-harburg.de

### Recap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam

Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine

### Advanced use of the C language

Advanced use of the C language Content Why to use C language Differences from Java Object oriented programming in C Usage of C preprocessor Coding standards Compiler optimizations C99 and C11 Standards

### Topic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History

Topic 6: A Quick Intro To C Reading Assumption: All of you know basic Java. Much of C syntax is the same. Also: Some of you have used C or C++. Goal for this topic: you can write & run a simple C program

### The C++ Language. Arizona State University 1

The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

### Chapter 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

### 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

### 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

198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book Computer Architecture What do computers do? Manipulate stored information

### 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,

### Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

### Basic data types. Building blocks of computation

Basic data types Building blocks of computation Goals By the end of this lesson you will be able to: Understand the commonly used basic data types of C++ including Characters Integers Floating-point values