Microcontroller Systems. ELET 3232 Topic 8: Structures, Arrays, & Pointers

Size: px
Start display at page:

Download "Microcontroller Systems. ELET 3232 Topic 8: Structures, Arrays, & Pointers"

Transcription

1 Microcontroller Systems ELET 3232 Topic 8: Structures, Arrays, & Pointers 1

2 Agenda Become familiar with and apply: Arrays Structures Pointers 2

3 Array Arrays A data set of a particular data type All elements of an array must be the same type Declared like any other variable except that you include the number of required array elements Ex: int digits[10]; char name[20]; 3

4 Array Initialization Arrays An array may be initialized as it s declared Place the values within braces Separate by commas Ex: int digits[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; char name[10] = {B, e, a, u b, a, d, i, n, e }; 4

5 Array Indexing A specific element of an array may be referenced through its index (or subscript) Ex: The first element of digits is digits[0] The ninth element of name is n int digits[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; char name[10] = {B, e, a, u b, a, d, i, n, e }; 5

6 Array Indexing A specific element of an array may be referenced through its index (or subscript) Ex: The first element of digits is digits[0] The ninth element of name is n int digits[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; char name[10] = {B, e, a, u b, a, d, i, n, e }; Index 0 through 9 6

7 Array Indexing A specific element of an array may be referenced through its index (or subscript) Ex: The first element of digits is digits[0] The ninth element of name is n int digits[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; char name[10] = {B, e, a, u b, a, d, i, n, e }; Index 0 through 9 7

8 Multidimensional Arrays C supports multidimensional arrays May be two, three, four or more dimensions Adjacent memory locations are referenced by the right-most index Example: int matrix [3][4] = { 0, 1, 2, 3 4, 5, 6, 7 8, 9, 10, 11}; matrix [1][2] = 6 the 5 and 7 are stored in adjacent memory locations (as opposed to the 2 and the 10) 8

9 Multidimensional Arrays C supports multidimensional arrays May be two, three, four or more dimensions Adjacent memory locations are referenced by the right-most index Example: Columns int matrix [3][4] = { 0, 1, 2, 3 4, 5, 6, 7 8, 9, 10, 11}; 0 Rows 1 2 9

10 Multidimensional Arrays C supports multidimensional arrays May be two, three, four or more dimensions Adjacent memory locations are referenced by the right-most index Example: int matrix [3][4] = { 0, 1, 2, 3 4, 5, 6, 7 8, 9, 10, 11}; What is the value of matrix [2][2]? 10

11 Multidimensional Arrays C supports multidimensional arrays May be two, three, four or more dimensions Adjacent memory locations are referenced by the right-most index Example: int matrix [3][4] = { 0, 1, 2, 3 4, 5, 6, 7 8, 9, 10, 11}; What is the value of matrix [2][2]? 10 11

12 STRUCTURES 12

13 Structure Structure A group of related variables under one name Used to create a single data object from one or more variables Variables within the structure are called members Structures are the fundamental element in OOP Structures can be thought of as an object Members are the properties of the object Members of a structure do not need to be of the same data type Richard H. Barnet, Sarah Cox, Larry O'Cull (2006), Embedded C Programming And The Atmel AVR, Delmar Learning, 2 edition 13

14 Structure Structure declaration format struct structure_tag_name { type variable1; type variable2; : type variablex; }; 14

15 Structure Example Structure example struct structure_name { type variable1; type variable2; : type variablex; }; struct employee_info { char name[20]; char id[9]; char month; char day; int year; } employee[20]; An array of 20 employee_info data types referred to as employee. In the structure is their name (20 characters), their employee id number (9 characters), their birthdates (month, day, year). 15

16 Structure Example Structure example struct structure_name { type variable1; type variable2; : type variablex; }; struct employee_info { char name[20]; char id[9]; char month; char day; int year; } employee[20]; To access one of the members of the structure you use the member operator. So, to access the month of birth for each employee you would write: employee[x].month 16

17 Structure Example Structure example struct structure_name { type variable1; type variable2; : type variablex; }; struct employee_info { char name[20]; char id[9]; char month; char day; int year; } employee[20]; To access an employee s id you would write: employee[x].id 17

18 Structure Example Structure example struct structure_name { type variable1; type variable2; : type variablex; }; struct employee_info { char name[20]; char id[9]; char month; char day; int year; } employee[20]; To access the 1 st letter of an employee s id you would write: employee[x].id[0] 18

19 Nested Structures Nested Structures struct employee_info { char name[20]; char id[9]; struct BIRTH birthdate; } employee[20]; struct BIRTH { char month; char day; int year; }; 19

20 Nested Structures Example Example struct employee_info { char name[20]; char id[9]; struct BIRTH birthdate; } employee[20]; struct BIRTH { char month; char day; int year; }; To access the 4 th employee s year of birth you would write: employee[3].birthdate.year 20

21 Structures Example Example Construct a structure that holds the dimensions and the volume of a box. Declare a variable Box_1 that is of type box. 21

22 Structures Example Example Construct a structure that holds the dimensions and the volume of a box. Declare a variable Box_1 that is of type box. struct box { float height; float width; float depth; float volume; }; struct box Box_1; 22

23 Structures Example Example Initialize Box_1 so that its height is 2.3 in, width is 8.5 in and its depth is 4 in. 23

24 Structures Example Example Initialize Box_1 so that its height is 2.3 in, width is 8.5 in and its depth is 4 in. Box_1.height = 2.3; Box_1.width = 8.5; Box_1.depth = 4; 24

25 POINTERS 25

26 Pointers Pointers: Variables that contain the address of a variable, constant, function, or data object Pointer data type allocates enough memory to hold the address Usually a 16 or 24 bit address (depending on the amount of memory) Data may be 8-bit (char), or 16-bit (int), or 32-bit (float, long int). In this case the data is 8 bits wide. Data 0x3F 0x5A 0xF1 0x32 0x9B 0x38 0x4E Address 0x3248 0x3249 0x324A 0x324B 0x324C 0x324D 0x324E 16-bit addresses 26

27 Pointers Pointers: Declared with the indirection operator: * Assigned with the address operator: & Ex: Variable c may be assigned to address 0x324A, but the value of c is 0xF1 char *p; //p is a pointer to a character char c; //c is a character (unsigned 8-bit integer) c = 0xF1; //c is assigned the value (hex) 0xF1 p = &c; //p is assigned the address of c (p is pointing to c) c Data 0x3F 0x5A 0xF1 0x32 0x9B 0x38 0x4E Address 0x3248 0x3249 0x324A 0x324B 0x324C 0x324D 0x324E Address of c c is an 8-bit char, but p is a 16-bit address (a pointer) to a char 27

28 Pointers Example: char *p; char a, b; a =10; b =45; //p is a pointer to a character //a and b are characters (unsigned 8-bit integer) p = &a; //p is assigned the address of a (p is pointing to a) *p = b; //the memory location pointed to by p is assigned the value of b What is the value of a and b when this segment of code is finished? 28

29 Pointers Example: char *p; char a, b; a =10; b =45; //p is a pointer to a character //a and b are characters (unsigned 8-bit integer) p = &a; //p is assigned the address of a (p is pointing to a) *p = b; //the memory location pointed to by p is assigned the value of b What is the value of a and b when this segment of code is finished? a = b = 45; Equivalent to a = b; 29

30 Pointers Example: unsigned char *Port_B; Port_B = 0x1010; *Port_B = 0x38; What is the address of Port_B and what data is stored there? 30

31 Pointers Example: unsigned char *Port_B; Port_B = 0x1010; *Port_B = 0x38; What is the address of Port_B and what data is stored there? Port_B Address = 0x1010 Port_B Data = 0x38 31

32 Summary Applied: Arrays Structures Pointers 32

Memory, Data, & Addressing II CSE 351 Spring

Memory, Data, & Addressing II CSE 351 Spring Memory, Data, & Addressing II CSE 351 Spring 2018 http://xkcd.com/138/ Review Questions 1) If the word size of a machine is 64-bits, which of the following is usually true? (pick all that apply) a) 64

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

INTRODUCTION 1 AND REVIEW

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.

More information

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points

Final Exam. 11 May 2018, 120 minutes, 26 questions, 100 points Name: CS520 Final Exam 11 May 2018, 120 minutes, 26 questions, 100 points The exam is closed book and notes. Please keep all electronic devices turned off and out of reach. Note that a question may require

More information

Type Checking. Prof. James L. Frankel Harvard University

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

More information

Binghamton University. CS-211 Fall Pointers vs. Arrays

Binghamton University. CS-211 Fall Pointers vs. Arrays Pointers vs. Arrays 1 Array Values are Contiguous Right next to each other in memory int vec[6] int m [4][3]; vec[0] vec[1] vec[2] vec[3] vec[4] vec[5] m[0][0] m[0][1] m[0][2] m[1][0] m[1][1] m[1][2] m[2][0]

More information

CSE351: Memory, Data, & Addressing I

CSE351: Memory, Data, & Addressing I CSE351: Memory, Data, & Addressing I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis http://xkcd.com/138/

More information

Arrays. Comp Sci 1570 Introduction to C++ Array basics. arrays. Arrays as parameters to functions. Sorting arrays. Random stuff

Arrays. Comp Sci 1570 Introduction to C++ Array basics. arrays. Arrays as parameters to functions. Sorting arrays. Random stuff and Arrays Comp Sci 1570 Introduction to C++ Outline and 1 2 Multi-dimensional and 3 4 5 Outline and 1 2 Multi-dimensional and 3 4 5 Array declaration and An array is a series of elements of the same type

More information

The syntax of structure declaration is. struct structure_name { type element 1; type element 2; type element n;

The syntax of structure declaration is. struct structure_name { type element 1; type element 2; type element n; Structure A structure is a user defined data type. We know that arrays can be used to represent a group of data items that belong to the same type, such as int or float. However we cannot use an array

More information

primitive arrays v. vectors (1)

primitive arrays v. vectors (1) Arrays 1 primitive arrays v. vectors (1) 2 int a[10]; allocate new, 10 elements vector v(10); // or: vector v; v.resize(10); primitive arrays v. vectors (1) 2 int a[10]; allocate new, 10 elements

More information

CS561 Manju Muralidharan Priya Structures in C CS200 STRUCTURES. Manju Muralidharan Priya

CS561 Manju Muralidharan Priya Structures in C CS200 STRUCTURES. Manju Muralidharan Priya OBJECTIVES: CS200 STRUCTURES Manju Muralidharan Priya By the end of this class you will have understood: 1. Definition of a structure 2. Nested Structures 3. Arrays of structure 4. User defined data types

More information

Where we are going (today)

Where we are going (today) Where we are going (today) Q: How do we arrange bits in the memory of the computer? (why do we care? we want the computer to store many individual numbers) A: bytes and words 10110000 00001110 01000010

More information

Input And Output of C++

Input And Output of C++ Input And Output of C++ Input And Output of C++ Seperating Lines of Output New lines in output Recall: "\n" "newline" A second method: object endl Examples: cout

More information

3.3 Structures. Department of CSE

3.3 Structures. Department of CSE 3.3 Structures 1 Department of CSE Objectives To give an introduction to Structures To clearly distinguish between Structures from Arrays To explain the scenarios which require Structures To illustrate

More information

Hardware: Logical View

Hardware: Logical View Hardware: Logical View CPU Memory Bus Disks Net USB Etc. 1 Hardware: Physical View USB I/O controller Storage connections CPU Memory 2 Hardware: 351 View (version 0) instructions? Memory CPU data CPU executes

More information

Memory, Data, & Addressing II

Memory, Data, & Addressing II Memory, Data, & Addressing II CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson

More information

C Programming Language

C Programming Language C Programming Language Advantages over assembly language for microcontrollers: More portable Math functions Readability Maintainability Editing C End-of-line ignored Use line breaks/tabs/indent for readability

More information

Multi-Dimensional arrays

Multi-Dimensional arrays Multi-Dimensional arrays An array having more then one dimension is known as multi dimensional arrays. Two dimensional array is also an example of multi dimensional array. One can specify as many dimensions

More information

Module 6: Array in C

Module 6: Array in C 1 Table of Content 1. Introduction 2. Basics of array 3. Types of Array 4. Declaring Arrays 5. Initializing an array 6. Processing an array 7. Summary Learning objectives 1. To understand the concept of

More information

IV Unit Second Part STRUCTURES

IV Unit Second Part STRUCTURES STRUCTURES IV Unit Second Part Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure

More information

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani

Data Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani Data Types, Variables and Arrays OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani Identifiers in Java Identifiers are the names of variables, methods, classes, packages and interfaces. Identifiers must

More information

Survey. Motivation 29.5 / 40 class is required

Survey. Motivation 29.5 / 40 class is required Survey Motivation 29.5 / 40 class is required Concerns 6 / 40 not good at examination That s why we have 3 examinations 6 / 40 this class sounds difficult 8 / 40 understand the instructor Want class to

More information

ONE DIMENSIONAL ARRAYS

ONE DIMENSIONAL ARRAYS LECTURE 14 ONE DIMENSIONAL ARRAYS Array : An array is a fixed sized sequenced collection of related data items of same data type. In its simplest form an array can be used to represent a list of numbers

More information

Darshan Institute of Engineering & Technology for Diploma Studies Unit 5

Darshan Institute of Engineering & Technology for Diploma Studies Unit 5 1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different data types grouped together under a single name. Structure is

More information

Where we are going (today)

Where we are going (today) Where we are going (today) Q: How do we arrange bits in the memory of the computer? (why do we care? we want the computer to store many individual numbers) A: bytes and words 10110000 00001110 01000010

More information

Representation of Information

Representation of Information Representation of Information CS61, Lecture 2 Prof. Stephen Chong September 6, 2011 Announcements Assignment 1 released Posted on http://cs61.seas.harvard.edu/ Due one week from today, Tuesday 13 Sept

More information

UNIT-V. Structures. The general syntax of structure is given below: Struct <tagname> { datatype membername1; datatype membername2; };

UNIT-V. Structures. The general syntax of structure is given below: Struct <tagname> { datatype membername1; datatype membername2; }; UNIT-V Structures Structure is a very useful derived data type supported in c that allows grouping one or more variables of different data types with a single name. The general syntax of structure is given

More information

A First Book of ANSI C Fourth Edition. Chapter 8 Arrays

A First Book of ANSI C Fourth Edition. Chapter 8 Arrays A First Book of ANSI C Fourth Edition Chapter 8 Arrays Objectives One-Dimensional Arrays Array Initialization Arrays as Function Arguments Case Study: Computing Averages and Standard Deviations Two-Dimensional

More information

9. Arrays. Compound Data Types: type name [elements]; int billy [5];

9. Arrays. Compound Data Types: type name [elements]; int billy [5]; - 58 - Compound Data Types: 9. Arrays An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier.

More information

CMPE-013/L. Introduction to C Programming

CMPE-013/L. Introduction to C Programming CMPE-013/L Introduction to C Programming Bryant Wenborg Mairs Spring 2014 What we will cover in 13/L Embedded C on a microcontroller Specific issues with microcontrollers Peripheral usage Reading documentation

More information

Structures Unions and Enumerated Datatypes 224

Structures Unions and Enumerated Datatypes 224 STRUCTURES, UNIONS AND ENUMERATED DATA TYPES LEARNING OBJECTIVES After reading this chapter, the readers will be able to understand the purpose of the user defined data types Structures, Unions and Enumerated

More information

Binary Encodings for JavaScript Object Notation: JSON-B, JSON-C, JSON-D

Binary Encodings for JavaScript Object Notation: JSON-B, JSON-C, JSON-D Internet Engineering Task Force P. Hallam-Baker Internet-Draft Comodo Group Inc. Intended status: Standards Track June 11, 2013 Expires: December 13, 2013 Binary Encodings for JavaScript Object Notation:

More information

Final Exam. 12 December 2018, 120 minutes, 26 questions, 100 points

Final Exam. 12 December 2018, 120 minutes, 26 questions, 100 points Name: CS520 Final Exam 12 December 2018, 120 minutes, 26 questions, 100 points The exam is closed book and notes. Please keep all electronic devices turned off and out of reach. Note that a question may

More information

Structure, Union. Ashishprajapati29.wordpress.com. 1 What is structure? How to declare a Structure? Explain with Example

Structure, Union. Ashishprajapati29.wordpress.com. 1 What is structure? How to declare a Structure? Explain with Example Structure, Union 1 What is structure? How to declare a Structure? Explain with Example Structure s a collection of logically related data items of different data types grouped together under a single name.

More information

Binghamton University. CS-211 Fall Pointers vs. Arrays

Binghamton University. CS-211 Fall Pointers vs. Arrays Pointers vs. Arrays 1 Pointers in C Pointers are a special data type The VALUE of a pointer is an address The TYPE of a pointer is pointer to pointer to character pointer to integer pointer

More information

Practice problems Set 2

Practice problems Set 2 Practice problems Set 2 1) Write a program to obtain transpose of a 4 x 4 matrix. The transpose of matrix is obtained by exchanging the elements of each row with the elements of the corresponding column.

More information

A First Book of ANSI C Fourth Edition. Chapter 12 Structures

A First Book of ANSI C Fourth Edition. Chapter 12 Structures A First Book of ANSI C Fourth Edition Chapter 12 Structures Objectives Single Structures Arrays of Structures Passing and Returning Structures Unions (Optional) Common Programming and Compiler Errors A

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

Lecture 5: Arrays. A way to organize data. MIT AITI April 9th, 2005

Lecture 5: Arrays. A way to organize data. MIT AITI April 9th, 2005 Lecture 5: Arrays A way to organize data MIT AITI April 9th, 2005 1 What are Arrays? An array is a series of compartments to store data. Essentially a block of variables. In Java, arrays can only hold

More information

SC2004MBS 20x4 Characters MODBUS RTU Slave LCD

SC2004MBS 20x4 Characters MODBUS RTU Slave LCD SC004MBS 0x4 Characters MODBUS RTU Slave SC004MBS is a MODBUS slave device that receives data from a Master MODBUS device and display them on the panel. The is 0 x 4 characters in size and each character

More information

Computer Programming

Computer Programming Computer Programming Dr. Deepak B Phatak Dr. Supratik Chakraborty Department of Computer Science and Engineering Session: Introduction to Pointers Part 1 Dr. Deepak B. Phatak & Dr. Supratik Chakraborty,

More information

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11 ... 1/16 CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11 Alice E. Fischer February 3, 2016 ... 2/16 Outline Basic Types and Diagrams ... 3/16 Basic Types and Diagrams Types in C C has

More information

Chapter 7: Structuring the Data. Lecture7 1

Chapter 7: Structuring the Data. Lecture7 1 Chapter 7: Structuring the Data Lecture7 1 Topics Introduction to Structures Operations on Structures Using Structures with Arrays Using Structures with Pointers Passing Structures to and from Functions

More information

Today's Topics. CISC 458 Winter J.R. Cordy

Today's Topics. CISC 458 Winter J.R. Cordy Today's Topics Last Time Semantics - the meaning of program structures Stack model of expression evaluation, the Expression Stack (ES) Stack model of automatic storage, the Run Stack (RS) Today Managing

More information

a data type is Types

a data type is Types Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental

More information

Analyzing the command string for switch to input #

Analyzing the command string for switch to input # Marshall VSW-2200 Switcher Control Protocol Firmware Version: 3.3 Document edited 8-22-2016 (legacy command structures have been removed from this document) Serial Port (over USB) Setting: Baud rate :

More information

Prof. Carl Schultheiss MS, PE. CLASS NOTES Lecture 12

Prof. Carl Schultheiss MS, PE. CLASS NOTES Lecture 12 Prof. Carl Schultheiss MS, PE CLASS NOTES Lecture 12 In addition to the basic data types C supports user-defined data types. Userdefined data types allow the development of programs using data types that

More information

CS C Primer. Tyler Szepesi. January 16, 2013

CS C Primer. Tyler Szepesi. January 16, 2013 January 16, 2013 Topics 1 Why C? 2 Data Types 3 Memory 4 Files 5 Endianness 6 Resources Why C? C is exteremely flexible and gives control to the programmer Allows users to break rigid rules, which are

More information

UW CSE 351, Winter 2013 Final Exam

UW CSE 351, Winter 2013 Final Exam Full Name: Student ID #: UW CSE 351, Winter 2013 Final Exam March 20, 2013 2:30pm - 4:20pm Instructions: Write your full name and UW student ID number on the front of the exam. When the exam begins, make

More information

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types Data Types Declarations and Initializations Larry Caretto Computer Science 16 Computing in Engineering and Science February 7, 25 Outline Review last week Meaning of data types Integer data types have

More information

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19 Data Storage Geoffrey Brown Bryce Himebaugh Indiana University August 9, 2016 Geoffrey Brown, Bryce Himebaugh 2015 August 9, 2016 1 / 19 Outline Bits, Bytes, Words Word Size Byte Addressable Memory Byte

More information

Data Representation and Storage

Data Representation and Storage Data Representation and Storage Learning Objectives Define the following terms (with respect to C): Object Declaration Definition Alias Fundamental type Derived type Use size_t, ssize_t appropriately Use

More information

Chapter 8 Arrays and Strings. Objectives. Objectives (cont d.) Introduction. Arrays 12/23/2016. In this chapter, you will:

Chapter 8 Arrays and Strings. Objectives. Objectives (cont d.) Introduction. Arrays 12/23/2016. In this chapter, you will: Chapter 8 Arrays and Strings Objectives In this chapter, you will: Learn about arrays Declare and manipulate data into arrays Learn about array index out of bounds Learn about the restrictions on array

More information

Accelerating Information Technology Innovation

Accelerating Information Technology Innovation Accelerating Information Technology Innovation http://aiti.mit.edu Cali, Colombia Summer 2012 Lesson 04 Arrays What are Arrays? An array is a series of compartments to store data. Essentially a block of

More information

Data Representation and Storage. Some definitions (in C)

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

More information

Overview. The C programming model. The C programming model. The C programming model. The C programming model 1/23/2009. Real-time Systems D0003E

Overview. The C programming model. The C programming model. The C programming model. The C programming model 1/23/2009. Real-time Systems D0003E Overview Real-time Systems D0003E Lecture 2: Bit manipulation and hardware interfacing Burn/Wellings ch. 15 Leftovers from lecture 1 the C execution model bit-manipulation in C memory mapped I/O port-mapped

More information

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification

Application Note. Introduction AN2471/D 3/2003. PC Master Software Communication Protocol Specification Application Note 3/2003 PC Master Software Communication Protocol Specification By Pavel Kania and Michal Hanak S 3 L Applications Engineerings MCSL Roznov pod Radhostem Introduction The purpose of this

More information

C++ assign array values. C++ assign array values.zip

C++ assign array values. C++ assign array values.zip C++ assign array values C++ assign array values.zip 06/05/2009 [SOLVED] Assign an arrays values to another array Hello Using Static Arrays, C++ uses an odd method of assigning values? By Norehsa in forum

More information

Programming. Elementary Concepts

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

More information

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2017 CISC2200 Yanjun Li 1. Fall 2017 CISC2200 Yanjun Li 2

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2017 CISC2200 Yanjun Li 1. Fall 2017 CISC2200 Yanjun Li 2 Review Fall 2017 CISC2200 Yanjun Li 1 Outline Array Pointer Object-Oriented Programming Fall 2017 CISC2200 Yanjun Li 2 1 Computer Fall 2017 CISC2200 Yanjun Li 3 Array Arrays are data structures containing

More information

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2013 CISC2200 Yanjun Li 1. Fall 2013 CISC2200 Yanjun Li 2

Review. Outline. Array Pointer Object-Oriented Programming. Fall 2013 CISC2200 Yanjun Li 1. Fall 2013 CISC2200 Yanjun Li 2 Review Fall 2013 CISC2200 Yanjun Li 1 Outline Array Pointer Object-Oriented Programming Fall 2013 CISC2200 Yanjun Li 2 1 Array Arrays are data structures containing related data items of same type. An

More information

Example: Structure, Union. Syntax. of Structure: struct book { char title[100]; char author[50] ]; float price; }; void main( )

Example: Structure, Union. Syntax. of Structure: struct book { char title[100]; char author[50] ]; float price; }; void main( ) Computer Programming and Utilization ( CPU) 110003 Structure, Union 1 What is structure? How to declare a Structure? Explain with Example Structure is a collection of logically related data items of different

More information

CE4DMID01 COMMUNICATION PROTOCOL CONTENTS 1.0 INTRODUCTION

CE4DMID01 COMMUNICATION PROTOCOL CONTENTS 1.0 INTRODUCTION 11/11/2011 Pagina 1 di 11 ELECTRICITY ENERGY METER FIRMWARE 1.3 CE4DMID01 COMMUNICATION PROTOCOL CONTENTS 1.0 INTRODUCTION 2.0 DATA MESSAGE DESCRIPTION 2.1 Data field description 2.2 Data format 2.3 Description

More information

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA) COMP2121: Microprocessors and Interfacing Instruction Set Architecture (ISA) http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 Contents Memory models Registers Data types Instructions

More information

Maltepe University Computer Engineering Department. BİL 133 Algorithms and Programming. Chapter 8: Arrays

Maltepe University Computer Engineering Department. BİL 133 Algorithms and Programming. Chapter 8: Arrays Maltepe University Computer Engineering Department BİL 133 Algorithms and Programming Chapter 8: Arrays What is an Array? Scalar data types use a single memory cell to store a single value. For many problems

More information

CSCI 356 Fall 2017 : Practice Exam I DO NOT OPEN EXAM PACKET UNTIL INSTRUCTED TO DO SO YOU MAY FILL IN INFORMATION ON THE FRONT NOW

CSCI 356 Fall 2017 : Practice Exam I DO NOT OPEN EXAM PACKET UNTIL INSTRUCTED TO DO SO YOU MAY FILL IN INFORMATION ON THE FRONT NOW CSCI 356 Fall 2017 : Practice Exam I DO NOT OPEN EXAM PACKET UNTIL INSTRUCTED TO DO SO YOU MAY FILL IN INFORMATION ON THE FRONT NOW PLEASE TURN OFF ALL ELECTRONIC DEVICES ID#: Name: This exam is closed

More information

Lesson 06 Arrays. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Lesson 06 Arrays. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL Lesson 06 Arrays MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL Array An array is a group of variables (called elements or components) containing

More information

C expressions. (Reek, Ch. 5) 1 CS 3090: Safety Critical Programming in C

C expressions. (Reek, Ch. 5) 1 CS 3090: Safety Critical Programming in C C expressions (Reek, Ch. 5) 1 Shift operations Left shift: value > n Two definitions: logical version: discard the n

More information

EB289. Motorola Semiconductor Engineering Bulletin. C Macro Definitions for the MC68HC11F1 By John Bodnar Austin, Texas. Freescale Semiconductor, I

EB289. Motorola Semiconductor Engineering Bulletin. C Macro Definitions for the MC68HC11F1 By John Bodnar Austin, Texas. Freescale Semiconductor, I nc. Order this document by /D Motorola Semiconductor C Macro Definitions for the MC68HC11F1 By John Bodnar Austin, Texas Introduction Conventions With more microcontroller users moving to high level languages

More information

Tutorial 1: C-Language

Tutorial 1: C-Language Tutorial 1: C-Language Problem 1: Data Type What are the ranges of the following data types? int 32 bits 2 31..2 31-1 OR -2147483648..2147483647 (0..4294967295 if unsiged) in some machines int is same

More information

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators CSE 351: The Hardware/Software Interface Section 2 Integer representations, two s complement, and bitwise operators Integer representations In addition to decimal notation, it s important to be able to

More information

ME 461 C review Session Fall 2009 S. Keres

ME 461 C review Session Fall 2009 S. Keres ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help

More information

UNIVERSITY OF LIMERICK OLLSCOIL LUIMNIGH COLLEGE OF INFORMATICS & ELECTRONICS DEPARTMENT OF ELECTRONIC & COMPUTER ENGINEERING

UNIVERSITY OF LIMERICK OLLSCOIL LUIMNIGH COLLEGE OF INFORMATICS & ELECTRONICS DEPARTMENT OF ELECTRONIC & COMPUTER ENGINEERING UNIVERSITY OF LIMERICK OLLSCOIL LUIMNIGH COLLEGE OF INFORMATICS & ELECTRONICS DEPARTMENT OF ELECTRONIC & COMPUTER ENGINEERING MODULE CODE: MODULE TITLE: ET4131 Introduction to Computer Programming SEMESTER:

More information

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks). Understanding FAT 12 You need to address many details to solve this problem. The exercise is broken down into parts to reduce the overall complexity of the problem: Part A: Construct the command to list

More information

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language

Introduction to C++ Introduction. Structure of a C++ Program. Structure of a C++ Program. C++ widely-used general-purpose programming language Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup starting in 1979 based on C Introduction to C++ also

More information

Protocol of SOJI Fuel level sensor FJ-RS232/FJ-RS485 Version 1.0.2

Protocol of SOJI Fuel level sensor FJ-RS232/FJ-RS485 Version 1.0.2 Protocol of SOJI Fuel level sensor FJRS232/FJRS485 Version 1.0.2 Document preparion Full Name Title Prepared by Nguyen Duy Tan Engineer Approved by Quang Nguyen Project manager Date 1 October 2016 1 October

More information

SLCD Technical Note TN-100. Programming the SLCD bitmap / macro flash memory in an embedded system

SLCD Technical Note TN-100. Programming the SLCD bitmap / macro flash memory in an embedded system SLCD Technical Note TN-100 Programming the SLCD bitmap / macro flash memory in an embedded system December 3, 2004 Copyright Reach Technology Inc. 2004 All Rights Reserved Reach Technology, Inc. sales@reachtech.com

More information

Arrays. Defining arrays, declaration and initialization of arrays. Designed by Parul Khurana, LIECA.

Arrays. Defining arrays, declaration and initialization of arrays. Designed by Parul Khurana, LIECA. Arrays Defining arrays, declaration and initialization of arrays Introduction Many applications require the processing of multiple data items that have common characteristics (e.g., a set of numerical

More information

CENG 447/547 Embedded and Real-Time Systems. Review of C coding and Soft Eng Concepts

CENG 447/547 Embedded and Real-Time Systems. Review of C coding and Soft Eng Concepts CENG 447/547 Embedded and Real-Time Systems Review of C coding and Soft Eng Concepts Recall (C-style coding syntax) ; - Indicate the end of an expression {} - Used to delineate when a sequence of elements

More information

Memory, Data, & Addressing I

Memory, Data, & Addressing I Memory, Data, & Addressing I CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan http://xkcd.com/953/

More information

Fundamentals of Programming. Lecture 12: C Structures, Unions, Bit Manipulations and Enumerations

Fundamentals of Programming. Lecture 12: C Structures, Unions, Bit Manipulations and Enumerations Fundamentals of Programming Lecture 12: C Structures, Unions, Bit Manipulations and Enumerations Instructor: Fatemeh Zamani f_zamani@ce.sharif.edu Sharif University of Technology Computer Engineering Department

More information

BASIC ELEMENTS OF A COMPUTER PROGRAM

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

More information

Student Name: (in Capital Letters) CSE Introduction to Programming for Engineers and Scientists. Final Exam

Student Name: (in Capital Letters) CSE Introduction to Programming for Engineers and Scientists. Final Exam Student Name: (in Capital Letters) CSE 1311 Introduction to Programming for Engineers and Scientists Final Exam Fall 2013 1 1. If count is a properly defined integer variable, the following piece of code:

More information

Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays)

Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays) Lecture 2 Arrays, Searching and Sorting (Arrays, multi-dimensional Arrays) In this lecture, you will: Learn about arrays Explore how to declare and manipulate data into arrays Understand the meaning of

More information

Introduction to C++ with content from

Introduction to C++ with content from Introduction to C++ with content from www.cplusplus.com 2 Introduction C++ widely-used general-purpose programming language procedural and object-oriented support strong support created by Bjarne Stroustrup

More information

C Programming Review CSC 4320/6320

C Programming Review CSC 4320/6320 C Programming Review CSC 4320/6320 Overview Introduction C program Structure Keywords & C Types Input & Output Arrays Functions Pointers Structures LinkedList Dynamic Memory Allocation Macro Compile &

More information

Order this document by EB285/D Motorola Semiconductor Engineering Bulletin EB285 C Macro Definitions for the MC68HC(7)11E20 By John Bodnar

Order this document by EB285/D Motorola Semiconductor Engineering Bulletin EB285 C Macro Definitions for the MC68HC(7)11E20 By John Bodnar nc. Order this document by /D Motorola Semiconductor C Macro Definitions for the MC68HC(7)11E20 By John Bodnar Austin, Texas Introduction Conventions With more microcontroller users moving to high level

More information

C++ Structures Programming Workshop 2 (CSCI 1061U)

C++ Structures Programming Workshop 2 (CSCI 1061U) C++ Structures Programming Workshop 2 (CSCI 1061U) Faisal Qureshi http://faculty.uoit.ca/qureshi University of Ontario Institute of Technology C++ struct struct keyword can be used to define new data types

More information

LEXICAL 2 CONVENTIONS

LEXICAL 2 CONVENTIONS LEXIAL 2 ONVENTIONS hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. ++ Programming Lexical onventions Objectives You will learn: Operators. Punctuators. omments. Identifiers. Literals. SYS-ED \OMPUTER EDUATION

More information

Week 3 Lecture 2. Types Constants and Variables

Week 3 Lecture 2. Types Constants and Variables Lecture 2 Types Constants and Variables Types Computers store bits: strings of 0s and 1s Types define how bits are interpreted They can be integers (whole numbers): 1, 2, 3 They can be characters 'a',

More information

IF96017 MODBUS COMMUNICATION PROTOCOL

IF96017 MODBUS COMMUNICATION PROTOCOL CONTENTS 1.0 ABSTRACT 04/07/14 Pagina 1 di 9 MULTIFUNCTION FIRMWARE 1.00 COMMUNICATION PROTOCOL IF96017 MODBUS COMMUNICATION PROTOCOL 2.0 DATA MESSAGE DESCRIPTION 2.1 Parameters description 2.2 Data format

More information

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS

Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 ARRAYS Kingdom of Saudi Arabia Princes Nora bint Abdul Rahman University College of Computer Since and Information System CS242 1 ARRAYS Arrays 2 Arrays Structures of related data items Static entity (same size

More information

EB287. Motorola Semiconductor Engineering Bulletin. C Macro Definitions for the MC68HC(7)11E9/E8/E1/E0. Freescale Semiconductor, I.

EB287. Motorola Semiconductor Engineering Bulletin. C Macro Definitions for the MC68HC(7)11E9/E8/E1/E0. Freescale Semiconductor, I. Order this document by Motorola Semiconductor C Macro Definitions for the MC68HC(7)11E9/E8/E1/E0 By John Bodnar Austin, Texas Introduction With more microcontroller users moving to high level languages

More information

FOR Loop. FOR Loop has three parts:initialization,condition,increment. Syntax. for(initialization;condition;increment){ body;

FOR Loop. FOR Loop has three parts:initialization,condition,increment. Syntax. for(initialization;condition;increment){ body; CLASSROOM SESSION Loops in C Loops are used to repeat the execution of statement or blocks There are two types of loops 1.Entry Controlled For and While 2. Exit Controlled Do while FOR Loop FOR Loop has

More information

CS 241 Data Organization Binary

CS 241 Data Organization Binary CS 241 Data Organization Binary Brooke Chenoweth University of New Mexico Fall 2017 Combinations and Permutations In English we use the word combination loosely, without thinking if the order of things

More information

Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types

Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types Chapter 6 Topics WEEK E FOUR Data Types Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference

More information

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012 Data Abstractions National Chiao Tung University Chun-Jen Tsai 05/23/2012 Concept of Data Structures How do we store some conceptual structure in a linear memory? For example, an organization chart: 2/32

More information

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park Variables in C CMSC 104, Fall 2012 John Y. Park 1 Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement 2 What Are Variables in C? Variables in C have the

More information

Chapter-14 STRUCTURES

Chapter-14 STRUCTURES Chapter-14 STRUCTURES Introduction: We have seen variables of simple data types, such as float, char, and int. Variables of such types represent one item of information: a height, an amount, a count, and

More information