Programming for MSc Part I
|
|
- Maude Terry
- 7 years ago
- Views:
Transcription
1 Herbert Martin Dietze University of Buckingham July 24, 2001 Abstract The course introduces the C programming language and fundamental software development techniques. These lectue notes by no means cover the course contents as they are merely intended to support the lecture. Thanks to Prof. Dr. Uwe Schmidt for teaching me C and giving me a lot of inspiration
2 July 24, 2001 Contents 1. Fundamentals (a) Programming Language Elements (b) Compiling, Linking and Running Programs (c) C Language Elements (d) Branching 2. Scalar Data Types (a) What Scalar Types are (b) Operations on Scalar Types (c) Introduction to Boolean Algebra (d) Enumerations (e) Defining own Types (f) Pointers (g) Increment and Decrement 3. Aggregate Data Types (a) Arrays (b) Structs 4. Control Flow (a) Loops (b) Advanced Branching 5. Dynamic Data structures (a) Allocating and Releasing Memory (b) List Structures 6. The Preprocessor and Macros Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 1
3 July 24, 2001 (a) The Preprocessors (b) Macros Herbert Martin Dietze 2
4 Part 1: Fundamentals (a) Programming Language Elements Computers and Humans Humans can use intuition to solve problems The computer only executes a sequences of instructions Simple operations (addition, comparison), but high speed Questions: Which instructions and in what order? Describe rules to solve a problem Algorithm Simple examples: A cooking recipe, or x 2 = x x A computer can t understand an algorithm without our help Not every algorithm can be made a computer program Computer Programs and Programming Languages A Computer Program can be executed on a computer A computer program implements an algorithm The computer program is written in a Programming Language The programmer creates a Source File Then a special computer program, the Compiler is invoked The Compiler generates machine code from the source file Every processor type uses its own machine language Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 3
5 Part 1: Fundamentals Programming Language Elements Low and High Level Programming Languages We call low level programming languages Assembly Languages Assembly language is a processor s language s readable form Primitive instructions, very close to the processor High level programming languages are processor independent More complex instructions, high abstraction level Some high level programming languages: Pascal, C, C++,... The C Programming Language Developed in the early seventies for the Unix operating system Later: ANSI standard Operating systems written in C: Windows, Unix, OS/2,... Popular general purpose programming language Small set of instructions, relatively little abstraction Example C Source Source file fiveptwo.c: int main (void) { 5*5; return 0; } Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 4
6 Part 1: Fundamentals Programming Language Elements Human Languages Analogy A programming language is just a language It consists of Characters, Words and Sentences We call them Tokens, Expressions and Statements Tokens A token is the smallest unit C can handle Atom Expressions consist of one or more tokens Examples: Text C Tokens hugo hugo *9 6, *, 9 (4+2)*9 (, 4, +, 2, ), *, 9 The compiler will always form the longest-possible token To avoid ambiguity rules for creating tokens are needed Expressions Expressions are what sentences are made of They can be just constants: 42 Operators can make expressions more complex: 6*9 Every expression has a value Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 5
7 Part 1: Fundamentals Programming Language Elements Statements A statement ( sentence ) is a command we want to execute It ends with a semicolon ; or a closing brace } An Empty statement contains nothing: ; An Expression statement consist of one expression: 5*5; A Compound statement bundles many to one: {5*5; 6*6;} There are some more categories of statements Example Let s take another look at fiveptwo.c: int main (void) { 5*5; return 0; } A list of two statements between { and } That consist of expressions: 5*5 and return 0 That consist of tokens: {, 5, *, 5, ;, return, 0, ;, } And some stuff we don t know yet Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 6
8 Part 1: Fundamentals (b) Compiling, Linking and Running Programs From the Source to an Executable Program The compiler compiles every file to machine language The result is one Object File for every source file The Linker bundles object files to an executable file The executable file can only be run on the target platform.c File.c File.c File.c File cc cc cc cc.o File.o File.o File.o File ld Library Executable Program Herbert Martin Dietze 7
9 Part 1: Fundamentals Compiling, Linking and Running Programs What a Program can do Technically a program only pushes 1s and 0s around From a our point of view it talks with the operating system Several categories of operations Input read something from a file or the keyboard Output write something to a file or the screen Arithmetics calculate something Data manipulation e.g. text, images etc. Operating systems and toolkits provide help for complex tasks: GUI windows Database access etc. These operations come in Libraries We don t want to reinvent the wheel! The C standard library The C language itself is rather primitive The C standard library is the standard toolkit for C programs It provides things like high mathematics (e.g. trigonometric functions), input and output etc. The linker will search the standard library automatically No useful C program without using the standard library Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 8
10 Part 1: Fundamentals Compiling, Linking and Running Programs A closer Look at the Compiler Compiling a C source involves two steps: 1. The Preprocessor expands Preprocessing directives that can be used to create macros or include other source files 2. The Compiler analyzes the result and generates machine code from it if there were no errors Source files that are not syntactically correct will be rejected Object files are no complete executable files! The Linker The linker bundles code from object files and libraries It also adds things needed by the operating system Complex programs consist of many modules The linker resolves dependencies Running an Executable File The operating system loads the program code into memory In every program there must be a entry point for execution The operating system now jumps to that entry point and starts executing instruction by instruction In a C program execution starts at main () Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 9
11 Part 1: Fundamentals Compiling, Linking and Running Programs C in the Unix Enviroment On Unix systems the compiler for C sources is cc (or gcc) The linker is ld The Linker normally gets invoked by the compiler The following commands compile and link the source fiveptwo.c to creae an executable file fiveptwo: herbert@paola:~/src $ gcc -c fiveptwo.c herbert@paola:~/src $ gcc -o fiveptwo fiveptwo.o herbert@paola:~/src $ _ Or all in one command: herbert@paola:~/src $ gcc -o fiveptwo fiveptwo.c herbert@paola:~/src $ _ We can now run the program: herbert@paola:~/src $./fiveptwo herbert@paola:~/src $ _ Does it do anything at all??? Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 10
12 Part 1: Fundamentals Compiling, Linking and Running Programs So what s 5*5 now? fiveptwo calculates fine, but how do we know the result? Solution: We need to output the result We therefore have to extend our source: #include <stdio.h> int main (void) { printf ("%d\n", 5*5); return 0; } printf () is a utility from the Standard C Library It outputs text to the screen The #include statement is an instruction to the preprocessor Now we can see the result: herbert@paola:~/src $ gcc -o fiveptwo fiveptwo.c herbert@paola:~/src $./fiveptwo 25 herbert@paola:~/src $ _ Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 11
13 Part 1: Fundamentals (c) C Language Elements Syntax Like a human language there are a set of rules The compiler can only work on syntactically correct sources Some rules: Statements end with semicolons or a closing braces There is a set of operators There is a set of reserved keywords On syntax errors the compiler will issue an error message Example for a syntax error in source file foo.c (does not end with semicolon or closing brace): #include <stdio.h> int main (void) { printf ("Hello World.\n") return 0; } herbert@paola:~/src $ gcc -c foo.c foo.c: In function main : foo.c:6: parse error before return herbert@paola:~/src $ _ Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 12
14 Part 1: Fundamentals C Language Elements Types Any kind of data in C has a type A type is a name for a category of data C has a list of builtin types (e.g. int for integer numbers or char for characters) You can t compare apples and oranges! Functions A function calculates something and returns the result We already know functions: Entering a number and then pressing the sin key on a pocket calculator In C a Function Definition looks like this: Return-Type Name (Arguments) Compound-Statement Between all those elements we can have any number of whitespaces (tabulators, newlines etc.) Example: int answer (void) { return 6*9-12; } Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 13
15 Part 1: Fundamentals C Language Elements Definitions vs. Declarations A complete function with body is called Function Definition There can be only one definition of the same function A function declaration looks like this: Return-Type Name (Arguments); The same funtion can be declared more than once Important: The compiler uses them to check the way we call the functions If missing: a function returning int is assumed Function declarations are also called Function Prototypes Definition and declaration must be consistent Header Files Header files are usually #include d by the preprocessor They contain declarations of all kinds: function prototypes, types, macros System headers are included by #include <headername.h> For our own headers we use #include "headername.h" Example: #include <stdio.h> for printf() and friends Header Files are the glue between modules in C Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 14
16 Part 1: Fundamentals C Language Elements Variables A variable is an object in memory that can store data Values are assigned using the assignment operator = Example: Output the results of 6 9 and Inefficient solution: printf ("%d\n", 6*9); printf ("%d\n", 6*9-12); Better: Store the result of 6 9 in a variable, output it, then calculate on and output the second result: int result; result = 6*9; printf ("%d\n", result); result = result - 12; printf ("%d\n", result); Creating Variables There are different kinds of variable declarations The simplest form is: Type Name; We can also create more than one variable: int a, b; This can only be done at the start of a Compound Statement or outside functions Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 15
17 Part 1: Fundamentals C Language Elements Variables Properties A variable is identified by its name A variable must be given a type Name and type chosen for a variable must be legal A variable must have been declared before use Values assigned to variables must be of compatible types After creation a variable has a random value Global and Local Variables Variables defined in compound statements are local They are invisible outside their block Variables defined outside compound statements are global They are visible through the whole source file Global variables should not be used side effects Example: int global; int foo (void) { int local = global; return local; } Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 16
18 Part 1: Fundamentals C Language Elements Function Arguments Function arguments are a special kind of variables They get initialized when the function is called They are ordinary local variables to their function Example: #include <stdio.h> int plustwo (int value); int main (void) { int fourty = 40; printf ("%d + 2 is %d\n", fourty, plustwo (fourty)); return 0; } int plustwo (int value) { return value + 2; } Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 17
19 Part 1: Fundamentals C Language Elements Comments Comments are used to document source code They get ignored by the compiler Comments are all between /* and */ It is good style to comment function heads or blocks Nesting comments (/* /*... */ */) does not work! There are a lot of different ways to format comments Matter of taste! Example: /* * This function adds 2 to value and * returns the result */ int another_plustwo (int value) { /* using the previous one-liner is more elegant, still this works well, too! */ value = value + 2; return value; } Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 18
20 Part 1: Fundamentals C Language Elements Names Names are used e.g. for functions or variables They can be almost freely chosen, but: C s builtin keywords are reserved They re not allowed to start with numbers They re not allowed to contain any special characters but the underscore Names starting with are reserved for system use There can be only one sybol of name name in one block Names Examples: legal illegal j j5 system name CaPiTaLS or NoT 5J $name int bad%$&name Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 19
21 Part 1: Fundamentals C Language Elements Reserved Words These words are reserved by the C language: auto double int struct break else long switch case enum register typedef char extern return union const float short unsigned continue for signed void default goto sizeof volatile do if static while Basic Input and Output The printf() utility performs formatted output Example: printf ("A number: %d\n", 42) The scanf() utility performs formatted input Input must be written to a variable s address We get a variable s address using the & operator The Format string is mostly like in printf() Normally only the placeholders are needed Example: scanf ("%d", &var) But what if the user does not enter an integer? scanf() does not help us here! More sophisticated methods will come later! Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 20
22 Part 1: Fundamentals C Language Elements Example using printf and scanf #include <stdio.h> int getnum (void); /* main program: get input and display * the result. */ int main (void) { int value = getnum (); printf ("That was %d\n", value); return 0; } /* Prompt the user for an integer number * and return the result. No checks for * valid input format are performed. */ int getnum (void) { int num; printf ("Enter integer number!\n"); scanf ("%d", &num); return num; } Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 21
23 Part 1: Fundamentals C Language Elements Simple Arithmetics and Logical Expressions For integer numbers there are several arithmetic operators: a + b a - b a * b a / b a % b adds a to b subtracts b from a multiplies a by b divides a by b discarding the rest returns the rest of the division a by b Comparing expressions: a == b a!= b a > b a < b a >= b a <= b a equals b (not the same as a = b!) a does not equal b a is greater than b a is less than b a is greater or equal to b a is less or equal to b Combining expressions: expr1 && expr2 expr1 expr2!expr expr1 and expr2 are both true At least expr1 or expr2 is true The opposite of expr In C logical expressions are of the type int A false condition resolves to 0 A true condition resolves to something not equal to 0 Herbert Martin Dietze <herbert@the-little-red-haired-girl.org> 22
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
More informationSources: 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,
More informationThe 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
More informationKeywords 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
More informationInformatica 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)
More informationC++ 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
More informationAbout 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.
More informationThe 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
More informationComputer Programming Tutorial
Computer Programming Tutorial COMPUTER PROGRAMMING TUTORIAL by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Computer Prgramming Tutorial Computer programming is the act of writing computer
More informationMoving 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
More informationName: 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
More informationIntroduction 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
More informationC++ INTERVIEW QUESTIONS
C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get
More informationKITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
More informationPART-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
More informationChapter 13 Storage classes
Chapter 13 Storage classes 1. Storage classes 2. Storage Class auto 3. Storage Class extern 4. Storage Class static 5. Storage Class register 6. Global and Local Variables 7. Nested Blocks with the Same
More informationC 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
More informationIntroduction 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
More informationHow 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
More informationEmbedded 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
More informationTopics. 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
More informationObjective-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
More informationChapter 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
More informationKeil 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
More informationTutorial on C Language Programming
Tutorial on C Language Programming Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:
More informationPROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE
PROGRAMMING IN C CONTENT AT A GLANCE 1 MODULE 1 Unit 1 : Basics of Programming Unit 2 : Fundamentals Unit 3 : C Operators MODULE 2 unit 1 : Input Output Statements unit 2 : Control Structures unit 3 :
More informationC PROGRAMMING FOR MATHEMATICAL COMPUTING
UNIVERSITY OF CALICUT SCHOOL OF DISTANCE EDUCATION BSc MATHEMATICS (2011 Admission Onwards) VI Semester Elective Course C PROGRAMMING FOR MATHEMATICAL COMPUTING QUESTION BANK Multiple Choice Questions
More informationPerl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl
First CGI Script and Perl Perl in a nutshell Prof. Rasley shebang line tells the operating system where the Perl interpreter is located necessary on UNIX comment line ignored by the Perl interpreter End
More informationEl Dorado Union High School District Educational Services
El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming II (#495) Rationale: A continuum of courses, including advanced classes in technology is needed.
More informationPemrograman 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
More informationBoolean 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
More informationAn 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
More informationVB.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
More informationMISRA-C:2012 Standards Model Summary for C / C++
MISRA-C:2012 Standards Model Summary for C / C++ The LDRA tool suite is developed and certified to BS EN ISO 9001:2000. This information is applicable to version 9.4.2 of the LDRA tool suite. It is correct
More informationPhys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions
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
More informationJAVA - 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
More information1 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
More informationarrays C Programming Language - Arrays
arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)
More informationFirst 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
More informationC++ 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
More informationC Interview Questions
http://techpreparation.com C Interview Questions And Answers 2008 V i s i t T e c h P r e p a r a t i o n. c o m f o r m o r e i n t e r v i e w q u e s t i o n s a n d a n s w e r s C Interview Questions
More informationObject 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
More informationScoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)
Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking
More informationStacks. Linear data structures
Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations
More informationLecture 5: Java Fundamentals III
Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd
More informationProgramming Microcontrollers in C
Programming Microcontrollers in C Second Edition Ted Van Sickle A Volume in the EMBEDDED TECHNOLOGY TM Series Eagle Rock, Virginia www.llh-publishing.com Programming Microcontrollers in C 2001 by LLH Technology
More informationCS 241 Data Organization Coding Standards
CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.
More informationComputer Programming I & II*
Computer Programming I & II* Career Cluster Information Technology Course Code 10152 Prerequisite(s) Computer Applications, Introduction to Information Technology Careers (recommended), Computer Hardware
More informationWe will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.
LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.
More informationObject 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
More informationLecture 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
More informationChapter 2: Elements of Java
Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction
More informationExample 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]);
More informationCSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals
CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]
More informationSemantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
More informationHandout 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
More informationEmbedded C Programming, Linux, and Vxworks. Synopsis
Embedded C Programming, Linux, and Vxworks. Synopsis This course is extensive and contains many advanced concepts. The range of modules covers a full introduction to C, real-time and embedded systems concepts
More informationBachelors 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
More informationEl Dorado Union High School District Educational Services
El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming I (#494) Rationale: A continuum of courses, including advanced classes in technology is needed.
More information1 Introduction. 2 An Interpreter. 2.1 Handling Source Code
1 Introduction The purpose of this assignment is to write an interpreter for a small subset of the Lisp programming language. The interpreter should be able to perform simple arithmetic and comparisons
More informationJavaScript: Control Statements I
1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can
More informationHow 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
More informationBeyond the Mouse A Short Course on Programming
1 / 22 Beyond the Mouse A Short Course on Programming 2. Fundamental Programming Principles I: Variables and Data Types Ronni Grapenthin Geophysical Institute, University of Alaska Fairbanks September
More informationChapter 13 - The Preprocessor
Chapter 13 - The Preprocessor Outline 13.1 Introduction 13.2 The#include Preprocessor Directive 13.3 The#define Preprocessor Directive: Symbolic Constants 13.4 The#define Preprocessor Directive: Macros
More informationTopics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives
Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,
More informationPrograming 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
More informationASCII 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
More informationChapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named
More informationPROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON
PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London
More informationOutline. 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
More informationProgramming Languages
Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately
More information8.5. <summary>...26 9. Cppcheck addons...27 9.1. Using Cppcheck addons...27 9.1.1. Where to find some Cppcheck addons...27 9.2.
Cppcheck 1.72 Cppcheck 1.72 Table of Contents 1. Introduction...1 2. Getting started...2 2.1. First test...2 2.2. Checking all files in a folder...2 2.3. Excluding a file or folder from checking...2 2.4.
More information9 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
More informationCS 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)
More informationChapter 1 Java Program Design and Development
presentation slides for JAVA, JAVA, JAVA Object-Oriented Problem Solving Third Edition Ralph Morelli Ralph Walde Trinity College Hartford, CT published by Prentice Hall Java, Java, Java Object Oriented
More informationHow to Think Like a Computer Scientist
How to Think Like a Computer Scientist C Version Allen B. Downey C-Version by Thomas Scheffler Version 1.08 November 25th, 2012 2 Copyright (C) 1999 Allen B. Downey This book is an Open Source Textbook
More informationC / 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
More informationIntroduction to Python
Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment
More informationC Programming Tutorial
C Programming Tutorial C PROGRAMMING TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i C O P Y R I G H T & D I S C L A I M E R N O T I C E All the content and graphics on this tutorial
More informationBasic 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
More informationCourse Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies)
Course Name: ADVANCE COURSE IN SOFTWARE DEVELOPMENT (Specialization:.Net Technologies) Duration of Course: 6 Months Fees: Rs. 25,000/- (including Service Tax) Eligibility: B.E./B.Tech., M.Sc.(IT/ computer
More informationCourse Title: Software Development
Course Title: Software Development Unit: Customer Service Content Standard(s) and Depth of 1. Analyze customer software needs and system requirements to design an information technology-based project plan.
More informationC Compiler Targeting the Java Virtual Machine
C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the
More informationLecture 7: Programming for the Arduino
Lecture 7: Programming for the Arduino - The hardware - The programming environment - Binary world, from Assembler to C - - Programming C for the Arduino: more - Programming style Lect7-Page1 The hardware
More informationObject Oriented Software Design II
Object Oriented Software Design II Introduction to C++ Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 20, 2012 G. Lipari (Scuola Superiore Sant Anna) C++ Intro February
More informationStorage 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
More informationSystem Calls and Standard I/O
System Calls and Standard I/O Professor Jennifer Rexford http://www.cs.princeton.edu/~jrex 1 Goals of Today s Class System calls o How a user process contacts the Operating System o For advanced services
More informationJava (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
More informationFundamentals 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
More information6. 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,
More informationCS 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
More informationLC-3 Assembly Language
LC-3 Assembly Language Programming and tips Textbook Chapter 7 CMPE12 Summer 2008 Assembly and Assembler Machine language - binary Assembly language - symbolic 0001110010000110 An assembler is a program
More informationChapter 7 Assembly Language
Chapter 7 Assembly Language Human-Readable Machine Language Computers like ones and zeros 0001110010000110 Humans like symbols ADD R6,R2,R6 increment index reg. Assembler is a program that turns symbols
More informationLecture 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
More informationECE 341 Coding Standard
Page1 ECE 341 Coding Standard Professor Richard Wall University of Idaho Moscow, ID 83843-1023 rwall@uidaho.edu August 27, 2013 1. Motivation for Coding Standards The purpose of implementing a coding standard
More informationI PUC - Computer Science. Practical s Syllabus. Contents
I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations
More informationProgramming with the Dev C++ IDE
Programming with the Dev C++ IDE 1 Introduction to the IDE Dev-C++ is a full-featured Integrated Development Environment (IDE) for the C/C++ programming language. As similar IDEs, it offers to the programmer
More informationSimple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language
Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from
More information