CS 202 Computer Science II Lab Fall 2009 September 17.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

Computer Science 1620 Math Library. Remember this program? suppose that I invest $25000 into a mutual fund that returns 8% per year. Write a program to.
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
Templated Functions. Overloading vs Templating  Overloaded functions allow multiple functions with the same name.
CS 202 Computer Science II Lab Fall 2009 November 5.
Writing and Testing Programs Drivers and Stubs Supplement to text.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Programming Switch command. COMP102 Prog. Fundamentals: Switch command / Slide 2 Multiple Selection: The switch Statement value1 action 1 value2 action.
Command-line arguments CS 201 Fundamental Structures of Computer Science.
CS 202 Computer Science II Lab Fall 2009 September 10.
CS 202 Computer Science II Lab Fall 2009 September 3.
CS 202 Computer Science II Lab Fall 2009 October 1.
CS 202 Computer Science II Lab Fall 2009 October 22.
CS 240: Data Structures Supplemental: Command Line Input.
Testing and Debugging Hakam Alomari
C++ Programming Language Day 1. What this course covers Day 1 – Structure of C++ program – Basic data types – Standard input, output streams – Selection.
1 The UNIX date command myclock.cpp example The C/C++ time() and ctime() functions myclock2.cpp example Inline function definitions Inline class member.
CS470/570 Lecture 5 Introduction to OpenMP Compute Pi example OpenMP directives and options.
Object Oriented Programming in C++ Dr. Hammadi Nait-Charif Media School Bournemouth University
GNU gcov (1/4) [from Wikipedia] gcov is a source code coverage analysis and statement- by-statement profiling tool. gcov generates exact counts of the.
Variables, Functions & Parameter Passing CSci 588 Fall 2013 All material not from online sources copyright © Travis Desell, 2011.
Separate Compilation. A key concept in programming  Two kinds of languages, compilation (C, Pascal, …) and interpretation (Lisp, …, Matlab, Phython,
Jan. 29, 2008(c) Mike Barnoske Introduction to Runtime Debugging Using the Visual C++ IDE COP 4331: OO Processes for SW Development © Dr. David A. Workman.
Functions Pass by Reference Alina Solovyova-Vincent Department of Computer Science & Engineering University of Nevada, Reno Fall 2005.
ITEC 320 C++ Examples.
Multiple Files. Monolithic vs Modular  one file before  system includes  main driver function  prototypes  function.
CSE 232: C++ debugging in Visual Studio and emacs C++ Debugging (in Visual Studio and emacs) We’ve looked at programs from a text-based mode –Shell commands.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 9.
1 10/18/04CS150 Introduction to Computer Science 1 Functions Divide and Conquer.
Lin Chen 09/06/2011. Global variables const int maxCandidates = 10; // Names of the candidates participating in this state's primary string candidate[maxCandidates];
CS Class 03 Topics  Sequence statements Input Output Assignment  Expressions Read pages Read pages 40 – 49 for next time.
#include using namespace std; // Declare a function. void check(int, double, double); int main() { check(1, 2.3, 4.56); check(7, 8.9, 10.11); } void check(int.
CS415 C++ Programming Takamitsu Kawai x4212 G11 CERC building WV Virtual Environments Lab West Virginia University.
Make: File Dependency System Lecturer: Prof. Andrzej (AJ) Bieszczad Phone: “UNIX for Programmers and Users” Third.
cs33201 Chapter 12 C Programming Tools Graham Glass and King Ables, UNIX for Programmers and Users, Third Edition, Pearson Prentice Hall, 2003.
Makefiles Problem: You are working on one part of a large programming project (e. g., MS Word).  It consists of hundreds of individual.c files all linked.
April 11, 2005 More about Functions. 1.Is the following a function call or a function header? calcTotal(); 2.Is the following a function call or a function.
Make Make is a system utility that automatically compiles your programs for you Make looks for a file named Makefile (or makefile) in the current directory.
Department of Computer Science and Engineering, HKUST 1 HKUST Summer Programming Course 2008 Using Member Functions and Data Members.
Reading from a file, Sorting, and a little Searching Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics,
Chapter Ten Developing UNIX Applications In C and C++
C++ Namespaces, Exceptions CSci 588: Data Structures, Algorithms and Software Design All material not from online sources copyright © Travis Desell, 2011.
CSIS 123A Lecture 7 Static variables, destructors, & namespaces.
MR. CRONE Generating Random Numbers. Random Numbers Many programs require the computer to generate random numbers Random numbers are used in many applications.
C++ Functions A bit of review (things we’ve covered so far)
Software Engineering Algorithms, Compilers, & Lifecycle.
Lecture 3: Getting Started & Input / Output (I/O)
Topic Pre-processor cout To output a message.
Chapter 6 CS 3370 – C++ Functions.
Intro to Programming Week # 6 Repetition Structure Lecture # 10
Compilation and Debugging
Compilation and Debugging
Command Line Arguments
CS 2304 Function Pointers & Lambda Functions
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Separate Compilation.
Code::Block vs Visual C++
Cs212: DataStructures Computer Science Department Lab 3 : Recursion.
Appendix F C Programming Environment on UNIX Systems
Separate Compilation.
Pointers and dynamic objects
Computer Terms Review from what language did C++ originate?
Functions Reasons Concepts Passing arguments to a function
Class rational part2.
Makefile Assignment Create a file called f1.cpp. It should contain the following function: int squareIt ( int x ) { //insert code to calc and return the.
SPL – PS1 Introduction to C++.
g++ features, better makefiles
Presentation transcript:

CS 202 Computer Science II Lab Fall 2009 September 17

Today Topics Basic makefile ACM Problem

Header file example… Create headerExample directory – *do not delete files Create basicMath.h file : 1./* basicMath.h */ 2. 3.int add (int a, int b); 4.int mul (int a, int b);

.Header file example.. Create basicMath.cpp file : 1./* basicMath.cpp */ 2.int add (int a, int b) { 3. return a+b; 4.} 5.int mul (int a, int b) { 6. return a*b; 7.}

..Header file example. Create main.cpp file : 1.#include 2.#include "basicMath.h" 3.using namespace std; 4.int main(int argc, char ** argv) { 5.int a, b; 6.cout << " Name: Your-Name " << endl; 7.cout << " Section: Your-Section-No " << endl; 8.if (argc > 2) { 9.a = atoi(argv[1]); 10.b = atoi(argv[2]); 11.} else { 12.a = 1; 13. b = 2; 14.} 15.cout << a << " + "<< b << " = " << add(a, b) << endl; 16.cout << a << " * "<< b << " = " << mul(a, b) << endl; 17.return 0; 18.}

Basic makefile Help to manage a project which might have multiple files associated with. Help programmers to compile source codes faster with shorter command line during development process

…Header file example – g++ -c main.cpp – g++ -c basicMath.cpp – Or: – g++ -c *.cpp – g++ -o main main.o basicMath.o –./main 12 5 > output.out

Basic makefile main main.obasicMath.o main.cppbasicMath.h basicMath.cpp

Basic makefile “makefile” is a series of rules which is invoked by “make” program make [-f makefile] – Preferred extension:.make – Default file: “makefile” targetList: dependencyList commandList

main.make main: main.o basicMath.o g++ -o main main.o basicMath.o main.o: main.cpp basicMath.h g++ -c main.cpp basicMath.o: basicMath.cpp basicMath.h g++ -c basicMath.cpp

Basic makefile make –f main.make

ACM ACM International Collegiate Programming Contest is an annual competition among the universities of the world. The contest is sponsored by IBM. (Wikipedia) ACM problem

Questions?