Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions
|
|
|
- Dulcie Anis Malone
- 9 years ago
- Views:
Transcription
1 Phys4051: C Lecture 2 & 3 Functions (Review) Comment Statements Variables & Operators Branching Instructions Comment Statements! Method 1: /* */! Method 2: // /* Single Line */ //Single Line /* This comment spans more than one line. */ // This comment // spans more than // one line. int x; //variable x 2 C Data Types! No Return Value: (For functions & pointers only!)! Integers:! Real (floating point):! void! char! short! int! long! float! double 3 1
2 Data Types: Signed / Unsigned! All integer data type declarations can be signed (default) or unsigned.! Example:! unsigned int ival = 134;! signed int sval = -107; 4 Global / Local Variables! All variables declared outside of a function are GLOBAL.! Global variables have global scope, i.e., they are seen in ALL the functions.! All variables declared within a function are LOCAL to that function.! Local variables have local scope. They "exist" only within the function that declares them. 5 Variable Declarations! Position in Program: Global vs. Local Always declare variables before any statements or before main! 6 2
3 Variable Initialization! Global Variables:! Always initialized to 0! Local Variables:! Never initialized! Random 7 Variable Declaration & Initialization! Example 1a:! Example 1b:! short x; short y; short z;! short x = 3, y =3, z; x = 3; y = 4; 8 C-Operators -Mathematical -Relational - Assignment -Logical -Bitwise 3
4 C-Operators! Are always executed:! 1: Left to right! 2: By order of precedent 10 Mathematical C-Operators! By order of precedence:! * Multiplication! / Division! % Remainder: ex 13%4 = 1! + Addition! - Subtraction 11 Mathematical C-Operators:! Accuracy:! When applying an operator to variables having different levels of accuracy, then the calculation is carried out using the level of accuracy as specified by the variable with the higher level of accuracy.! Example: 12 4
5 Mathematical C-Operators: Accuracy Example short k, m = 2, n = 3; float a, b = 2.0, c = 3.0; k = m / n; k = b / n; a = m / n; a = 1.0 * m / n; a = (float) m / n; //type casting a = b / c; k =? k =? a =? a =? a =? a =? 13 Mathematical C-Operators: Shortcut Notations Equivalent Notations: x = x + 1; x = x - 1; x++; x--; ++x; --x; a = a ; a = a ; a = a * 3.14; a = a / 3.14; a + = 3.14; a - = 3.14; a * = 3.14; a / = 3.14; 14 C-Operators: Shortcut Notations Example! Example 1:! Example 2 int y, x = 4051; y = ++x; printf("%d", y); int y, x = 4051; y = x++; printf("%d", y);! Output:! Output: 15 5
6 Branching Instructions: Simple if-statement! Example1:! if ( logic condition ) statement(s);! if ( x > 1 ) x = 0; printf( Hello ); 16 Logic Condition! TRUE: Anything, except 0 or FALSE! FALSE: Only 0 or FALSE! Example: if( 3 ) printf( always true );! Example: if( 0 ) printf( never true ); 17 if-else Statement! if( logic condition ) //executed only if logic statement(s); //condition is TRUE else //executed only if logic statement(s); //condition is FALSE 18 6
7 if-statement Shortcut Notation (1)! If the if-statement contains only ONE statement, braces can be omitted: if( x ) printf( TRUE ); else printf( FALSE ) Equivalent program segment: if( x ) printf( TRUE); else printf( FALSE); 19 if-statement Shortcut Notation (1) WARNING!!! if( x ) printf( TRUE ); else printf( FALSE ); printf( AGAIN ); printf( DONE ) if( x ) printf( TRUE ); else printf( FALSE ); printf( AGAIN ); printf( DONE ); 20 Relational Operators (1) < <= > >= Less Than Less Than and Equal Greater Than Greater Than and Equal ==!= Equal Not Equal 21 7
8 Relational Operators (2) WARNING: Equal Operator! Example 1:! Example 2: short x = 5; if( x = 3 ) printf( x is 3 ); Output: short x = 5; if( x == 3) printf( x is 3 ); Output: 22 Relational Operators (3) The Not (!) Operator What is the difference between the following two program segments? if(!x ) if( x == 0 ) 23 Logic Operators: AND & OR (1) The following operators act on the entire variable or expression as a whole and return either TRUE (1) or FALSE (0) && AND OR (shift \ key) 24 8
9 Logic Operators: (Bytewise) AND & OR (2)! The AND and OR operators are often used to link relational operators.! Example: How do you write 3 < x < 10 in C? 25 Logic Operators: Bitwise Operators (1) << >> ~ & ^ Left Shift Right Shift Bitwise NOT Bitwise AND Bitwise XOR Bitwise OR! Bitwise operators operate on a variable or expression bit by bit. 26 Bytewise and Bitwise Operators (2)! Example 1: Bytewise short a = 5, b = 10, y; y = a && b;! Example 2: Bitwise short a = 5, b = 10, y; y = a & b; y =??? y =??? 27 9
10 Logic Operators: Bitwise Operators (3)! Bitwise operators are often used in hardware control applications! Example 1: Check one specific bit in a byte (BIT MASKING)! Example 2: Toggle a specific bit in a byte 28 10
11 Typical C-Function Syntax Function Declaration double Thdeg( float x, float y) ; Function Header double Thdeg( float x, float y) Local float fthetadeg, fthetarad ; Variable float fpi = ; Declarations double ftan ; Statements ftan = y / x ; and fthetarad = atan ( ftan ) ; Function Calls fthetadeg = ftheta * 180.0/fPi ; return ( fthetadeg );
12 Data Type Range Bytes Signed Declaration Range Unsigned Declaration 1 char -128 to 127 unsigned char 2 short to (or: int) long to float ±3.4 E±38 8 double ±1.7 E±308 unsigned short (unsigned int) Range 0 to to to
13 Program Global & Local Variables #include <ansi_c.h> void F1( short x); void F2( short x); short s1; main() short sm1; short sm2 = 123; //Non-intialized values printf("part 1: Non-Initialized Variables\n"); printf("s1: %d\n", s1); printf("sm1: %d\n\n", sm1); printf("part 2: Passing a Variable to a Function\n"); printf("sm2: %d\n", sm2); F1( sm2 ); //passing a variable by value printf("sm2: %d\n\n", sm2); printf("global vs. Local Variables\n"); F2( sm2 ); //global vs. local variables printf("sm2: %d\n", sm2); printf("s1: %d\n\n", s1); void F1( short x) printf("before: x: %d\t", x); x = 888; printf("after: x: %d\n", x); void F2( short x) short sm2 = -111; s1 = -1234;
14 Output: Part 1: Non-Initialized Variables s1: sm1: Part 2: Passing a Variable to a Function sm2: before: x: after: x: sm2: Global vs. Local Variables sm2: s1:
15 1) ANSI-C / No GUI //Program MyMaxNoGui #include <ansi_c.h> float MyMax(float x, float y); main() float u = 123.0, v = ; float res; res = MyMax( u, v); printf("maximum is: %f\n", res); float MyMax(float x, float y) float max; if( x > y) max = x; else max = y; return max;
16 2) LabWindows / With GUI 2a) LabWindows Generated Code: #include <cvirte.h> #include <userint.h> #include "MyMaxGui.h" static int panelhandle; int main (int argc, char *argv[]) if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((panelhandle = LoadPanel (0, "MyMaxGui.uir", PANEL)) < 0) return -1; DisplayPanel (panelhandle); RunUserInterface (); return 0; int CVICALLBACK Quit (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) switch (event) case EVENT_COMMIT: QuitUserInterface (0); break; return 0; int CVICALLBACK CalcMax (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) switch (event) case EVENT_COMMIT: return 0; break;
17 2b) Code for MyMax function added (in Bold): #include <ansi_c.h> #include <cvirte.h> #include <userint.h> #include "MyMaxGui.h" static int panelhandle; float MyMax(float x, float y); int main (int argc, char *argv[]) if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((panelhandle = LoadPanel (0, "MyMaxGui.uir", PANEL)) < 0) return -1; DisplayPanel (panelhandle); RunUserInterface (); return 0; int CVICALLBACK Quit (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) switch (event) case EVENT_COMMIT: QuitUserInterface (0); break; return 0; int CVICALLBACK CalcMax (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) float u = 123.0, v = ; float res; switch (event) case EVENT_COMMIT: res = MyMax( u, v); printf("maximum is: %f\n", res); return 0; break;
18 float MyMax(float x, float y) float max; if( x > y) max = x; else max = y; return max; 2c) Code Added to Read Input and to Display the Result: (Changes from previous version are shown in bold) #include <ansi_c.h> #include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */ #include <userint.h> #include "MyMaxGui.h" static int panelhandle; float MyMax(float x, float y); int main (int argc, char *argv[]) if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */ return -1; /* out of memory */ if ((panelhandle = LoadPanel (0, "MyMaxGui.uir", PANEL)) < 0) return -1; DisplayPanel (panelhandle); RunUserInterface ();
19 return 0; int CVICALLBACK Quit (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) switch (event) case EVENT_COMMIT: QuitUserInterface (0); break; return 0; int CVICALLBACK CalcMax (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) float u, v; float res; switch (event) case EVENT_COMMIT: GetCtrlVal (panelhandle, PANEL_XINPUT, &u); GetCtrlVal (panelhandle, PANEL_XINPUT, &v); res = MyMax( u, v); return 0; SetCtrlVal (panelhandle, PANEL_RESULT, res); break; float MyMax(float x, float y) float max; if( x > y) max = x; else max = y; return max;
Sources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
Informatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
Keil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
Introduction to Java
Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high
Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362
PURDUE UNIVERSITY Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362 Course Staff 1/31/2012 1 Introduction This tutorial is made to help the student use C language
Comp151. Definitions & Declarations
Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const
Tutorial on C Language Programming
Tutorial on C Language Programming Teodor Rus [email protected] The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:
Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
The programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
Why using ATmega16? University of Wollongong Australia. 7.1 Overview of ATmega16. Overview of ATmega16
s schedule Lecture 7 - C Programming for the Atmel AVR School of Electrical, l Computer and Telecommunications i Engineering i University of Wollongong Australia Week Lecture (2h) Tutorial (1h) Lab (2h)
The C Programming Language course syllabus associate level
TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming
Example of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
AP Computer Science Java Subset
APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall
JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.
http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral
J a v a Quiz (Unit 3, Test 0 Practice)
Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points
DNA Data and Program Representation. Alexandre David 1.2.05 [email protected]
DNA Data and Program Representation Alexandre David 1.2.05 [email protected] Introduction Very important to understand how data is represented. operations limits precision Digital logic built on 2-valued
Operator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example
Operator Overloading Lecture 8 Operator Overloading C++ feature that allows implementer-defined classes to specify class-specific function for operators Benefits allows classes to provide natural semantics
Lecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
Chapter 5. Selection 5-1
Chapter 5 Selection 5-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow
ELEG3924 Microprocessor Ch.7 Programming In C
Department of Electrical Engineering University of Arkansas ELEG3924 Microprocessor Ch.7 Programming In C Dr. Jingxian Wu [email protected] OUTLINE 2 Data types and time delay I/O programming and Logic operations
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C
Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in
Object Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction
C++FA 5.1 PRACTICE MID-TERM EXAM
C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer
An Incomplete C++ Primer. University of Wyoming MA 5310
An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages
Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:
Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of
First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science
First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca
C++ Programming Language
C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract
Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements
9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending
Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language
Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description
CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
Pemrograman Dasar. Basic Elements Of Java
Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle
ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters
The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters
C++ Language Tutorial
cplusplus.com C++ Language Tutorial Written by: Juan Soulié Last revision: June, 2007 Available online at: http://www.cplusplus.com/doc/tutorial/ The online version is constantly revised and may contain
VB.NET Programming Fundamentals
Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming
UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything
Network Working Group. October 1990
Network Working Group Request for Comments: 1186 R. Rivest MIT Laboratory for Computer Science October 1990 The MD4 Message Digest Algorithm Status of this Memo This RFC is the specification of the MD4
Lecture 22: C Programming 4 Embedded Systems
Lecture 22: C Programming 4 Embedded Systems Today s Goals Basic C programming process Variables and constants in C Pointers to access addresses Using a High Level Language High-level languages More human
Java (12 Weeks) Introduction to Java Programming Language
Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short
Statements and Control Flow
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
Fundamentals of Programming
Fundamentals of Programming Introduction to the C language Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) The C language
13 Classes & Objects with Constructors/Destructors
13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.
C++ program structure Variable Declarations
C++ program structure A C++ program consists of Declarations of global types, variables, and functions. The scope of globally defined types, variables, and functions is limited to the file in which they
Passing 1D arrays to functions.
Passing 1D arrays to functions. In C++ arrays can only be reference parameters. It is not possible to pass an array by value. Therefore, the ampersand (&) is omitted. What is actually passed to the function,
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.
Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java
Moving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
KITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php [email protected] [email protected] Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
5 Arrays and Pointers
5 Arrays and Pointers 5.1 One-dimensional arrays Arrays offer a convenient way to store and access blocks of data. Think of arrays as a sequential list that offers indexed access. For example, a list of
Chapter One Introduction to Programming
Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
COS 217: Introduction to Programming Systems
COS 217: Introduction to Programming Systems 1 Goals for Todayʼs Class Course overview Introductions Course goals Resources Grading Policies Getting started with C C programming language overview 2 1 Introductions
CpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing
CpSc212 Goddard Notes Chapter 6 Yet More on Classes We discuss the problems of comparing, copying, passing, outputting, and destructing objects. 6.1 Object Storage, Allocation and Destructors Some objects
How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)
TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions
Java Interview Questions and Answers
1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java
C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands
C Programming for Embedded Microcontrollers Warwick A. Smith Elektor International Media BV Postbus 11 6114ZG Susteren The Netherlands 3 the Table of Contents Introduction 11 Target Audience 11 What is
Chapter 7D The Java Virtual Machine
This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly
1 Abstract Data Types Information Hiding
1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content
1.00/1.001 - Session 2 Fall 2004. Basic Java Data Types, Control Structures. Java Data Types. 8 primitive or built-in data types
1.00/1.001 - Session 2 Fall 2004 Basic Java Data Types, Control Structures Java Data Types 8 primitive or built-in data types 4 integer types (byte, short, int, long) 2 floating point types (float, double)
Chapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java
CS1020 Data Structures and Algorithms I Lecture Note #1 Introduction to Java Objectives Java Basic Java features C Java Translate C programs in CS1010 into Java programs 2 References Chapter 1 Section
Lecture 3. Arrays. Name of array. c[0] c[1] c[2] c[3] c[4] c[5] c[6] c[7] c[8] c[9] c[10] c[11] Position number of the element within array c
Lecture 3 Data structures arrays structs C strings: array of chars Arrays as parameters to functions Multiple subscripted arrays Structs as parameters to functions Default arguments Inline functions Redirection
Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)
Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating
Crash Course in Java
Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is
An Introduction to Assembly Programming with the ARM 32-bit Processor Family
An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2
Binary storage of graphs and related data
EÖTVÖS LORÁND UNIVERSITY Faculty of Informatics Department of Algorithms and their Applications Binary storage of graphs and related data BSc thesis Author: Frantisek Csajka full-time student Informatics
PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
Basic Programming and PC Skills: Basic Programming and PC Skills:
Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of
Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
Conditionals (with solutions)
Conditionals (with solutions) For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87;
Chapter 8 Selection 8-1
Chapter 8 Selection 8-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow
Member Functions of the istream Class
Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,
Chapter 3 Operators and Control Flow
Chapter 3 Operators and Control Flow I n this chapter, you will learn about operators, control flow statements, and the C# preprocessor. Operators provide syntax for performing different calculations or
About The Tutorial. Audience. Prerequisites. Copyright & Disclaimer
About The Tutorial C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system.
Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators
Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions
Objective-C Tutorial
Objective-C Tutorial OBJECTIVE-C TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Objective-c tutorial Objective-C is a general-purpose, object-oriented programming
3/13/2012. Writing Simple C Programs. ESc101: Decision making using if-else and switch statements. Writing Simple C Programs
Writing Simple C Programs ESc101: Decision making using if- and switch statements Instructor: Krithika Venkataramani Semester 2, 2011-2012 Use standard files having predefined instructions stdio.h: has
PIC 10A. Lecture 7: Graphics II and intro to the if statement
PIC 10A Lecture 7: Graphics II and intro to the if statement Setting up a coordinate system By default the viewing window has a coordinate system already set up for you 10-10 10-10 The origin is in the
COMPUTER SCIENCE 1999 (Delhi Board)
COMPUTER SCIENCE 1999 (Delhi Board) Time allowed: 3 hours Max. Marks: 70 Instructions: (i) All the questions are compulsory. (ii) Programming Language: C++ QUESTION l. (a) Why main function is special?
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui
Calling the Function. Two Function Declarations Here is a function declared as pass by value. Why use Pass By Reference?
Functions in C++ Let s take a look at an example declaration: Lecture 2 long factorial(int n) Functions The declaration above has the following meaning: The return type is long That means the function
C / C++ and Unix Programming. Materials adapted from Dan Hood and Dianna Xu
C / C++ and Unix Programming Materials adapted from Dan Hood and Dianna Xu 1 C and Unix Programming Today s goals ú History of C ú Basic types ú printf ú Arithmetic operations, types and casting ú Intro
Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit
Decimal Division Remember 4th grade long division? 43 // quotient 12 521 // divisor dividend -480 41-36 5 // remainder Shift divisor left (multiply by 10) until MSB lines up with dividend s Repeat until
Conditions & Boolean Expressions
Conditions & Boolean Expressions 1 In C++, in order to ask a question, a program makes an assertion which is evaluated to either true (nonzero) or false (zero) by the computer at run time. Example: In
Common Beginner C++ Programming Mistakes
Common Beginner C++ Programming Mistakes This documents some common C++ mistakes that beginning programmers make. These errors are two types: Syntax errors these are detected at compile time and you won't
Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014
German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Ahmed Gamal Introduction to Computer Programming, Spring Term 2014 Practice Assignment 3 Discussion 15.3.2014-20.3.2014
Embedded C Programming
Microprocessors and Microcontrollers Embedded C Programming EE3954 by Maarten Uijt de Haag, Tim Bambeck EmbeddedC.1 References MPLAB XC8 C Compiler User s Guide EmbeddedC.2 Assembly versus C C Code High-level
2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal
2/9/9 Binary number system Computer (electronic) systems prefer binary numbers Binary number: represent a number in base-2 Binary numbers 2 3 + 7 + 5 Some terminology Bit: a binary digit ( or ) Hexadecimal
6. Control Structures
- 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,
CS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper
Visual Basic Programming. An Introduction
Visual Basic Programming An Introduction Why Visual Basic? Programming for the Windows User Interface is extremely complicated. Other Graphical User Interfaces (GUI) are no better. Visual Basic provides
Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C
Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive
How To Write Portable Programs In C
Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important
Part I. Multiple Choice Questions (2 points each):
Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******
