Learning style reminder
|
|
- Coral Conley
- 7 years ago
- Views:
Transcription
1 Learning style reminder Please answer honestly: Have you written from scratch at least two short programs with each of these? if switch case while do while for rand() and srand()
2 Learning style reminder If you answered NO, please set aside a couple of hours this weekend for writing C code. If necessary, take another look at the file How to learn programming (webpage)
3 Chapter 6: Functions
4 Introduction Basic idea: By using functions, a large task is broken down into smaller ones, a.k.a. modularity. Why this is important/necessary: Keep the code small enough to understand it. Develop and test portions of the code separately, maybe even multiple programmers. Reusability: develop a program based upon what others have already done. Do not have to start from scratch.
5 Function Definitions return_type function_name(argument declaration) { Example: statements int addition(int a, int b) { int s; s = a + b; return s; int main() { int sum; sum = addition(3, 4); printf("sum = %d\n", sum); return 0;
6 The return type can be any valid type specifier. The return statement can be used to return a value from the called function to the calling function as in return expression; If necessary, the expression will be converted to the return type of the function. However, if the expression cannot be converted to the return type of the function according to the built-in C conversion rules, it is a syntax error. Example: int func(void){ double d; d = 4.6; return d; // Automatic type conversion, returns 4
7 If the return type is not void, a return statement is necessary at the end of the function in C99. A calling function can freely ignore the return value. Example: int func(int i){ return i+1; // the same as return (i+1); int main() { int j; j = func(4); func(5); return 0; // ignore the return value
8 If the return type is void, the return statement is optional. However, no expression should follow return, otherwise, it is a syntax error. Example: void func(int i){ if(i == 3){ printf("i is equal to 3 \n"); return i; else if(i > 3){ // ERROR: return int printf("i is not equal to 3 \n"); return; // OK i = -1; // return not necessary since return type is void int main(){ func(2); return 0;
9 The data type of an actual argument of the calling function can be different from that of the formal argument of the called function as long as they are compatible. The value of an actual argument will be converted to the data type of its formal definition according to the built-in data conversion rules implicitly at the function interface stage. Example: int func1(int i) { // argument type is int return 2*i; int main(){ func1(5); // OK func1(5.0); // OK, 5.0 converted to 5 return 0;
10 Sample Problem: The system in Figure1 (a) consists of a single body with mass m moving on a horizontal surface. An external force p acts on the body. The coefficient of kinetic friction between body and horizontal surface is. The freebody diagram for the system is shown in Figure1 (b). Figure1: The system diagram and FBD of a sample problem
11 Program 1: Use a function to calculate the external force. #include <stdio.h> #define M_G 9.81 double force(double t) { double p; p = 4*(t-3)+20; return p; int main() { double a, mu, m, p, t; mu = 0.2; m = 5.0; t = 2.0; p = force(t); a = (p-mu*m*m_g)/m; printf("acceleration a = %f (m/s^2)\n", a); return 0; Output: Acceleration a = (m/s^2)
12 #include <stdio.h> #define M_G 9.81 Program 2: Use functions that: have multiple arguments call other functions double force(double t) { double p; p = 4*(t-3)+20; return p; double accel(double t, double mu, double m) { double a, p; p = force(t); a = (p-mu*m*m_g)/m; return a; void main() { double a, mu, m, t; mu = 0.2; m = 5; t = 2; a = accel(t, mu, m); printf("acceleration a = %f\n (m/s^2)", a);
13 The types of the arguments and returned value need not be related in any way double force(int i, float f, long long LL ) {......
14 6.2 Function Prototypes Basic idea: abstraction, modularity and the black box: double accel(double t, double mu, double m) { double a, p; p = force(t); a = (p-mu*m*m_g)/m; return a; double t double mu double m Black box double accel
15 A function prototype: Declares only the interface of that function: return type types of all parameters Shouldn t this read the names and types? Parameter names must appear in function definitions, but they are optional in function prototypes. The following two function prototypes are the same: double accel(double, double, double); double accel(double t, double mu, double m);
16 A function prototype: Contains no function definition. Like the function definition itself, it cannot be inside the body of another function. Can be declared before or after its function definition, but widespread programming style is to have it before Actually, we ll be even more strict than this: Either put the entire function definition before main(), in which case do not use a prototype, or Put the prototype before main() and the definition after main().
17 #include <stdio.h> #define M_G 9.81 Program 3: Using function prototypes. double force(double t); double accel(double, double, double); void main() { double a, mu, m, t; mu = 0.2; m = 5.0; t = 2.0; a = accel(t, mu, m); printf("acceleration a = %f (m/s^2)\n", a); double force(double t) { double p; p = 4*(t-3)+20; return p; double accel(double t, double mu, double m) { double a, p; p = force(t); a = (p-mu*m*m_g)/m; return a;
18 Function prototype: no arguments In C, declaring a function without arguments may result in ambiguity, b/c the compiler does not check the calls to make sure they have no arguments, e.g. int foo(); void main(){... foo(42);... { //no compilation error! Solution: use void int foo( void );
19 Function prototype: no arguments In C++, explicitly specifying that a function requires no arguments is the same as declaring a function with an empty argument declaration list. Therefore, the following two statements are identical: int foo(); int foo( void );
20 We have covered sections 6.1 and 6.2 Solve the following end-of-chapter problems in notebook for next time: 2 5 6a
21 6.3 Calling functions by value or by reference Call by value the variables used as parameters are copied, then the copies are passed to the function If the parameters are changed inside the function, the change does not propagate to the original variables Call by reference the variables addresses are passed to the function If the parameters are changed inside the function, the change affects the original variables In C, the default is by value.
22 What s wrong with these functions? void increment (int x){ x++; void swap(int x, int y) { int temp; temp = x; x = y; y = temp;
23 Solution: call by reference void swap(int *x, int *y) { int temp;... *temp = *x; *x = *y; *y = *temp; swap (&a, &b); //call it like this
24 Extra-credit: rewrite to call by ref. and show how the main program will call it void increment (int x){ x++;
25 Another example: scanf("%d", &counter); Why not scanf("%d", counter);
26 6.4 Standard C Header Files and Libraries Header files contain function prototypes for performing operations that are related to one another. For example, math.h contains extern double sin(double x); extern double exp(double x); for the mathematical functions sin(x) and e x. The type qualifier extern means that the functions are defined outside of the header file (in a library or other module). Header files may also include macros and type definitions required by some of the functions, e.g. FLT _EPSILON in float.h INT_MIN and INT_MAX in limits.h typedef unsigned int size_t; in types.h
27 Each C compiler has its own header files for the standard C libraries C:\Program Files\Microsoft Visual Studio.NET 2003\Vc7\include
28 Some Standard C Header Files File limits.h float.h math.h stdbool.h stdio.h stdlib.h time.h Description Define several macros that expand to various limits and parameters of the standard integer types. Define several macros that expand to various limits and parameters of the standard floating-point types. Declare two types and several functions and define several macros for general mathematical operations. Define macros for boolean operations Declare types, macros, and functions for standard input and output. Declare several types, macros, and functions for general utility, such as conversion of numbers to text and text to numbers, memory allocation, and generation of random numbers. Define macros and declare sever types and functions for manipulating time and date.
29 A few snippets from math.h
30 6.5 Math functions and Type Generic functions A type generic function is a built-in system function that is polymorphic: Several versions of the TG function exist, that can handle various types of argument (e.g. float, double, complex) When the TG function such as sin(x) is called, the compiler chooses that version of sin() that matches the type of the argument x. To use type generic mathematical functions in C99, the header file tgmath.h shall be included instead of math.h TG math functions are not supported in MSVS.
31 Standard C functions Reference manuals with detailed description for each function in the standard C libraries are available on many websites, e.g. Use either website above to find the functions: sin() time()
32 6.6 Example: A Mathematical Formula with a Single Variable Calculate the function sinc(x) = sin(x)/x from -10 <= x <= 10 with a step size 5. Cardinal sine Generate data points (x, y) for x in the range x0 <= x <= xf with step size xstep linearly. The number of points should be n = (xf x0)/xstep + 1; Each data point can be calculated in a for loop: for(i = 0; i <n; i++) { x = x0 + i*xstep; y = f(x);
33 /* File: sinc.c */ #include <stdio.h> /* for printf() */ #include <math.h> /* for sin() and fabs() */ #include <float.h> /* for FLT_EPSILON */ Output: x sinc(x) double sinc(double x) { double retval; if(fabs(x) < FLT_EPSILON) retval = 1.0; else retval = sin(x)/x; return retval; int main() { double x, x0, xf, xstep, result; int i, n; Explain this! printf(" x sinc(x)\n"); printf(" \n"); x0 = -10.0; /* initial value */ xf = 10.0; /* final value */ xstep = 5.0; /* step size */ n = (xf - x0)/xstep + 1; /* num of points */ for(i = 0; i < n; i++) { x = x0 + i*xstep; /* value x */ result = sinc(x); printf("%8.4f %8.4f\n", x, result); return 0;
34 C x for Engineers and Scientists: An Interpretive Approach Example: A Mathematical Formula with Multiple Variables Calculate the function f 2 ( x, y) sin( x x 2 2 y y 2 2 ) for x from -10 <= x <= 10 with a step size 10 and y from -10 <= y <= 10 with a step size of 10.
35 /* File: sinr.c */ #include <stdio.h> #include <math.h> double sinr(double x, double y) { double retval, r; r = sqrt(x*x + y*y); retval = sin(r)/r; return retval; int main() { double x, x0, xf, xstep, y, y0, yf, ystep, result; int i, j, nx, ny; printf(" x y sinr(x,y)\n"); printf(" \n"); x0 = -10.0; xf = 10.0; xstep = 10.0; nx = (xf - x0)/xstep + 1; /* num of points for x */
36 y0 = -10.0; yf = 10.0; ystep = 10.0; ny = (yf - y0)/ystep + 1; /* num of points for y */ for(i = 0; i < nx; i++) { x = x0 + i*xstep; /* calculate value for x */ for(j = 0; j <ny; j++) { y = y0 + j*ystep; /* calculate value for y */ result = sinr(x, y); printf("%10.4f %10.4f %8.4f\n", x, y, result);
37 y0 = -10.0; yf = 10.0; ystep = 10.0; ny = (yf - y0)/ystep + 1; /* num of points for y */ for(i = 0; i < nx; i++) { x = x0 + i*xstep; /* caclulate value for x */ for(j = 0; j <ny; j++) { y = y0 + j*ystep; /* calculate value for y */ result = sinr(x, y); printf("%10.4f %10.4f %8.4f\n", x, y, result); Output: sin(0)/0 is NaN x y sinr(x,y) NaN
38 SKIP for now 6.7 Plotting Functions
39 Local variables in functions double force(double t) { double p; p = 4*(t-3)+20; return p; int main() { double a, mu, m, p, t; mu = 0.2; m = 5.0; t = 2.0; p = force(t); a = (p-mu*m*m_g)/m; printf("acceleration a = %f (m/s^2)\n", a); return 0;
40 We have covered sections 6.3, 6.4, 6.5, 6.6 Solve the following end-of-chapter problems in notebook for next time: 3 4 6b
41 6.8 Recursive Functions Functions in C may be used recursively: a function calls itself! Each function call will have a new set of local variables. Recursive functions usually contain conditional statements, such as if-else, to allow exit of the function and return control to the calling function. A function may also call itself indirectly.
42 Example: Calculating the factorial iteratively, using a function with a for-loop. #include <stdio.h> unsigned int factorial(int n); int main() { int i; for(i=0; i<=5; i++) printf("%d! = %d\n", i, factorial(i)); return 0; unsigned int factorial(int n) { unsigned int i, f; Output: 0! = 1 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 for(i=1, f=1; i<=n; i++) { f *= i; return f;
43 Example: Calculating the factorial recursively using a function that calls itself: #include <stdio.h> unsigned int factorial(int n); int main() { int i; for(i=0; i<=5; i++) printf("%d! = %u\n", i, factorial(i)); return 0; unsigned int factorial(int n) { if(n == 0) { // n == 1 also works return 1; else { return n*factorial(n-1); Output: 0! = 1 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120
44 Another example of recursion Problem 16/219 the Fibonacci numbers
45
46 6.10 Finding Roots of Equations Using Bisection Method
47 The bisection method Read and understand: Program 6.17 (pseudocode) Program 6.18 (iterative solution) Not in text: recursive implementation of bisection!
48 Recursion detail: storage classes static variables are initialized only once, no matter how many times the block (function) in which they are defined is called during execution! In C, the default storage class is auto but it s almost never written! More details in Ch.8.
49 6.9 func Double underscore on each side! In C99 it is a static, constant string Use this in Visual Studio (uppercase!). It s a macro (#define)
50 SKIP 6.11, 6.12, 6.13 End of chapter problems: 6 b, c 7 b, c a Homework for Ch.6 Due Friday, Oct Hint: First enter the original program 6.18 in Visual Studio and make sure it works. Only then modify it! Extra-credit: Re-write program 6.18 using a recursive function
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,
More informationCP Lab 2: Writing programs for simple arithmetic problems
Computer Programming (CP) Lab 2, 2015/16 1 CP Lab 2: Writing programs for simple arithmetic problems Instructions The purpose of this Lab is to guide you through a series of simple programming problems,
More informationC Programming. Charudatt Kadolkar. IIT Guwahati. C Programming p.1/34
C Programming Charudatt Kadolkar IIT Guwahati C Programming p.1/34 We want to print a table of sine function. The output should look like: 0 0.0000 20 0.3420 40 0.6428 60 0.8660 80 0.9848 100 0.9848 120
More informationFEEG6002 - Applied Programming 5 - Tutorial Session
FEEG6002 - Applied Programming 5 - Tutorial Session Sam Sinayoko 2015-10-30 1 / 38 Outline Objectives Two common bugs General comments on style String formatting Questions? Summary 2 / 38 Objectives Revise
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 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 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 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 informationPseudo code Tutorial and Exercises Teacher s Version
Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy
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 informationChapter 5 Functions. Introducing Functions
Chapter 5 Functions 1 Introducing Functions A function is a collection of statements that are grouped together to perform an operation Define a function Invoke a funciton return value type method name
More informationThe Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!
The Tower of Hanoi Recursion Solution recursion recursion recursion Recursive Thinking: ignore everything but the bottom disk. 1 2 Recursive Function Time Complexity Hanoi (n, src, dest, temp): If (n >
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 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 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 informationFunctions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; }
Functions Recursion C++ functions Declare/prototype int myfunction (int ); Define int myfunction (int x){ int y = x*x; return y; Call int a; a = myfunction (7); function call flow types type of function
More informationData Structures. Algorithm Performance and Big O Analysis
Data Structures Algorithm Performance and Big O Analysis What s an Algorithm? a clearly specified set of instructions to be followed to solve a problem. In essence: A computer program. In detail: Defined
More informationAppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction
AppendixA1A1 Java Language Coding Guidelines A1.1 Introduction This coding style guide is a simplified version of one that has been used with good success both in industrial practice and for college courses.
More informationJava Program Coding Standards 4002-217-9 Programming for Information Technology
Java Program Coding Standards 4002-217-9 Programming for Information Technology Coding Standards: You are expected to follow the standards listed in this document when producing code for this class. Whether
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 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 informationQUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1
QUIZ-II Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For
More informationAn Introduction to the WEB Style of Literate Programming
An Introduction to the WEB Style of Literate Programming Literate Programming by Bart Childs One of the greatest needs in computing is the reduction of the cost of maintenance of codes. Maintenance programmers
More informationv v ax v a x a v a v = = = Since F = ma, it follows that a = F/m. The mass of the arrow is unchanged, and ( )
Week 3 homework IMPORTANT NOTE ABOUT WEBASSIGN: In the WebAssign versions of these problems, various details have been changed, so that the answers will come out differently. The method to find the solution
More informationC++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
More informationEmbedded 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 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 information16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution
16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more
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 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 informationDebugging. 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
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 informationSenem Kumova Metin & Ilker Korkmaz 1
Senem Kumova Metin & Ilker Korkmaz 1 A loop is a block of code that can be performed repeatedly. A loop is controlled by a condition that is checked each time through the loop. C supports two categories
More informationMasters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013
Masters programmes in Computer Science and Information Systems Object-Oriented Design and Programming Sample module entry test xxth December 2013 This sample paper has more questions than the real paper
More informationMULTIPLE 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
More informationC Programming Language
C Programming Language Lecture 4 (10/13/2000) Instructor: Wen-Hung Liao E-mail: whliao@cs.nccu.edu.tw Extension: 62028 Building Programs from Existing Information Analysis Design Implementation Testing
More informationCSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis. Linda Shapiro Winter 2015
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Linda Shapiro Today Registration should be done. Homework 1 due 11:59 pm next Wednesday, January 14 Review math essential
More informationExperiment: Static and Kinetic Friction
PHY 201: General Physics I Lab page 1 of 6 OBJECTIVES Experiment: Static and Kinetic Friction Use a Force Sensor to measure the force of static friction. Determine the relationship between force of static
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 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 informationBSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering
BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security & BSc. (Hons.) Software Engineering Cohort: BIS/05/FT BCNS/05/FT BSE/05/FT Examinations for 2005-2006 / Semester
More information7th Marathon of Parallel Programming WSCAD-SSC/SBAC-PAD-2012
7th Marathon of Parallel Programming WSCAD-SSC/SBAC-PAD-2012 October 17 th, 2012. Rules For all problems, read carefully the input and output session. For all problems, a sequential implementation is given,
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 information0 Introduction to Data Analysis Using an Excel Spreadsheet
Experiment 0 Introduction to Data Analysis Using an Excel Spreadsheet I. Purpose The purpose of this introductory lab is to teach you a few basic things about how to use an EXCEL 2010 spreadsheet to do
More informationIllustration 1: Diagram of program function and data flow
The contract called for creation of a random access database of plumbing shops within the near perimeter of FIU Engineering school. The database features a rating number from 1-10 to offer a guideline
More informationIS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points
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 informationPL / SQL Basics. Chapter 3
PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic
More informationCourse: Programming II - Abstract Data Types. The ADT Stack. A stack. The ADT Stack and Recursion Slide Number 1
Definition Course: Programming II - Abstract Data Types The ADT Stack The ADT Stack is a linear sequence of an arbitrary number of items, together with access procedures. The access procedures permit insertions
More informationProblem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class
CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class This homework is to be done individually. You may, of course, ask your fellow classmates for help if you have trouble editing files,
More informationStatic vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer
Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis
More informationUsing the RDTSC Instruction for Performance Monitoring
Using the Instruction for Performance Monitoring http://developer.intel.com/drg/pentiumii/appnotes/pm1.htm Using the Instruction for Performance Monitoring Information in this document is provided in connection
More informationInstall Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html
CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install
More informationKnow or Go Practical Quest for Reliable Software
Know or Go Practical Quest for Reliable Software Dr.-Ing. Jörg Barrho Dr.-Ing. Ulrich Wünsche AVACS Project meeting 25.09.2014 2014 Rolls-Royce Power Systems AG The information in this document is the
More informationPostgreSQL Functions By Example
Postgre joe.conway@credativ.com credativ Group January 20, 2012 What are Functions? Introduction Uses Varieties Languages Full fledged SQL objects Many other database objects are implemented with them
More informationCurriculum Map. Discipline: Computer Science Course: C++
Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code
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 informationMultichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is
Multichoice Quetions 1. Atributes a. are listed in the second part of the class box b. its time is preceded by a colon. c. its default value is preceded by an equal sign d. its name has undereline 2. Associations
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 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 informationClasses and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:
In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our
More informationSubtopics - Functions Function Declaration Function Arguments Return Statements and values. By Hardeep Singh
Subtopics - Functions Function Declaration Function Arguments Return Statements and values FUNCTIONS Functions are building blocks of the programs. They make the programs more modular and easy to read
More informationManagement Information Systems 260 Web Programming Fall 2006 (CRN: 42459)
Management Information Systems 260 Web Programming Fall 2006 (CRN: 42459) Class Time: 6:00 8:05 p.m. (T,Th) Venue: WSL 5 Web Site: www.pbvusd.net/mis260 Instructor Name: Terrell Tucker Office: BDC 127
More informationFigure 1: Graphical example of a mergesort 1.
CSE 30321 Computer Architecture I Fall 2011 Lab 02: Procedure Calls in MIPS Assembly Programming and Performance Total Points: 100 points due to its complexity, this lab will weight more heavily in your
More information1 Using CWEB with Microsoft Visual C++ CWEB INTRODUCTION 1
1 Using CWEB with Microsoft Visual C++ CWEB INTRODUCTION 1 1. CWEB Introduction. The literate programming technique is described by Donald Knuth in Literate Programming and The CWEB System for Structured
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 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 informationProgramming Database lectures for mathema
Programming Database lectures for mathematics students April 25, 2015 Functions Functions are defined in Postgres with CREATE FUNCTION name(parameter type,...) RETURNS result-type AS $$ function-body $$
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 informationMicrocontroller Systems. ELET 3232 Topic 8: Slot Machine Example
Microcontroller Systems ELET 3232 Topic 8: Slot Machine Example 1 Agenda We will work through a complete example Use CodeVision and AVR Studio Discuss a few creative instructions Discuss #define and #include
More informationqwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq
qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui
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 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 informationModule 816. File Management in C. M. Campbell 1993 Deakin University
M. Campbell 1993 Deakin University Aim Learning objectives Content After working through this module you should be able to create C programs that create an use both text and binary files. After working
More informationCGN 3421 - Computer Methods
CGN 3421 - Computer Methods Class web site: www.ce.ufl.edu/~kgurl Class text books: Recommended as a reference Numerical Methods for Engineers, Chapra and Canale Fourth Edition, McGraw-Hill Class software:
More informationChapter 1: Key Concepts of Programming and Software Engineering
Chapter 1: Key Concepts of Programming and Software Engineering Software Engineering Coding without a solution design increases debugging time - known fact! A team of programmers for a large software development
More informationChapter 7: Additional Topics
Chapter 7: Additional Topics In this chapter we ll briefly cover selected advanced topics in fortran programming. All the topics come in handy to add extra functionality to programs, but the feature you
More informationCalling 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
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 informationThe C Programming Language
Chapter 1 The C Programming Language In this chapter we will learn how to write simple computer programs using the C programming language; perform basic mathematical calculations; manage data stored in
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 informationExercise 1: Python Language Basics
Exercise 1: Python Language Basics In this exercise we will cover the basic principles of the Python language. All languages have a standard set of functionality including the ability to comment code,
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 informationOutput: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;
50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)
More informationCOMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing
COMP 356 Programming Language Structures Notes for Chapter 4 of Concepts of Programming Languages Scanning and Parsing The scanner (or lexical analyzer) of a compiler processes the source program, recognizing
More informationDNA Data and Program Representation. Alexandre David 1.2.05 adavid@cs.aau.dk
DNA Data and Program Representation Alexandre David 1.2.05 adavid@cs.aau.dk Introduction Very important to understand how data is represented. operations limits precision Digital logic built on 2-valued
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 informationLabVIEW Day 1 Basics. Vern Lindberg. 1 The Look of LabVIEW
LabVIEW Day 1 Basics Vern Lindberg LabVIEW first shipped in 1986, with very basic objects in place. As it has grown (currently to Version 10.0) higher level objects such as Express VIs have entered, additional
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 informationCommon 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
More informationDesigning with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219
Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing
More informationCoding Rules. Encoding the type of a function into the name (so-called Hungarian notation) is forbidden - it only confuses the programmer.
Coding Rules Section A: Linux kernel style based coding for C programs Coding style for C is based on Linux Kernel coding style. The following excerpts in this section are mostly taken as is from articles
More informationChapter 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
More informationCOMPUTER SCIENCE. Paper 1 (THEORY)
COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) -----------------------------------------------------------------------------------------------------------------------
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 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 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 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 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 information