CSC 107 - Programming for Science Lecture 37 : Course Review.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Introduction to C Programming
C Language.
L2:CSC © Dr. Basheer M. Nasef Lecture #2 By Dr. Basheer M. Nasef.
Chapter 7 - Functions. Functions u Code group that performs single task u Specification refers to what goes into and out of function u Design refers to.
1 9/10/07CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
1 Lecture-4 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
1 Homework Turn in HW2 at start of next class. Starting Chapter 2 K&R. Read ahead. HW3 is on line. –Due: class 9, but a lot to do! –You may want to get.
Structure of a C program
C Programming Language 4 Developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories 4 Used to rewrite the UNIX operating system 4 Widely used on UNIX.
1 9/8/08CS150 Introduction to Computer Science 1 Data Types Section 2.7 – 2.12 CS 150 Introduction to Computer Science I.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
CSC Programming for Science Lecture 22: Random Numbers & Macros.
CS150 Introduction to Computer Science 1
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
Basic Elements of C++ Chapter 2.
CSC 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
Elements of a C++ program 1. Review Algorithms describe how to solve a problem Structured English (pseudo-code) Programs form that can be translated into.
Chapter 2 : Overview of C By Suraya Alias. /*The classic HelloWorld */ #include int main(void) { printf(“Hello World!!"); return 0; }
CSC 107 – Programming For Science. Announcements.
CSC 107 – Programming For Science. Announcements  Textbook available from library’s closed reserve.
C Tokens Identifiers Keywords Constants Operators Special symbols.
CSC 107 – Programming For Science. Today’s Goal  Discuss writing & using functions  How to declare them, use them, & trace them  Could write programs.
CPS120: Introduction to Computer Science Variables and Constants Lecture 8 - B.
1 Programs Composed of Several Functions Syntax Templates Legal C++ Identifiers Assigning Values to Variables Declaring Named Constants String Concatenation.
CPS120: Introduction to Computer Science
COMPUTER PROGRAMMING. Functions What is a function? A function is a group of statements that is executed when it is called from some point of the program.
1 C++ Syntax and Semantics, and the Program Development Process.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
PHY 107 – Programming For Science. Announcements  Slides, activities, & solutions always posted to D2L  Note-taking versions before class, for those.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
CSC 107 – Programming For Science. Today’s Goal  When lecture over, start understanding pointers  What a pointer is and what it is not  Why pointers.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
CSC 212 – Data Structures Lecture 37: Course Review.
BASICS CONCEPTS OF ‘C’.  C Character Set C Character Set  Tokens in C Tokens in C  Constants Constants  Variables Variables  Global Variables Global.
CSC 107 – Programming For Science. The Week’s Goal.
 2007 Pearson Education, Inc. All rights reserved C Structures, Unions, Bit Manipulations and Enumerations.
C Functions Three major differences between C and Java functions: –Functions are stand-alone entities, not part of objects they can be defined in a file.
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
1 Chapter 2 C++ Syntax and Semantics, and the Program Development Process.
CSC 107 – Programming For Science. Today’s Goal  Discuss writing functions that return values  return statement’s meaning and how it works  When and.
Engineering Problem Solving with C Fundamental Concepts Chapter 4 Modular Programming with Functions.
CHAPTER 2 C++ SYNTAX & SEMANTICS #include using namespace std; int main() { cout
CSC Programming for Science Lecture 36: Structures.
CSC Programming for Science Lecture 4: Beginning Programming.
CPS120: Introduction to Computer Science Variables and Constants.
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
CSC Programming for Science Lecture 28: Multi-dimensional Arrays.
Introduction to Computers and Programming Class 24 Structures (structs) Professor Avi Rosenfeld.
Chapter 4: More Object Concepts. Objectives Understand blocks and scope Overload a method Avoid ambiguity Create and call constructors with parameters.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CSC 107 – Programming For Science. Final Exams Dec. 16, 8AM – 10AM in OM221  Exam for CSC107: Dec. 16, 8AM – 10AM in OM221  Will be done using paper.
PHY 107 – Programming For Science. Science Means Solving Problems  Physics – How does an atom work?
CSC 107 – Programming For Science. Today’s Goal  Discover best uses of structures in a program  How we can mix pointers inside structures  Assigning.
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Programming Fundamentals Enumerations and Functions.
Chapter 7 - Functions. Functions u Code group that performs single task u Specification refers to what goes into and out of function u Design refers to.
ECE 103 Engineering Programming Chapter 30 C Functions Herbert G. Mayer, PSU CS Status 8/9/2014 Initial content copied verbatim from ECE 103 material developed.
Announcements. Practice questions, with and without solutions will be uploaded by Friday 5 th November, make sure to check them before the weekend \\netstorage\Subjects\ITCA-b\Exam.
CSC 107 – Programming For Science. Today’s Goal  Write functions that take & return values  How parameters declared and how we call functions  What.
BIL 104E Introduction to Scientific and Engineering Computing Lecture 4.
Chapter # 2 Part 2 Programs And data
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
Lecture2.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Chapter # 2 Part 2 Programs And data
C Language B. DHIVYA 17PCA140 II MCA.
Presentation transcript:

CSC Programming for Science Lecture 37 : Course Review

Final Exam Tuesday, Dec. 12 from in OM 208 Plan for exam to take full 2 hours Exam covers material from entire semester  Format will be like that of 2 midterms  Still open-book, open-note, closed-computer

Discover how computers can solve important scientific problems Learn basics of software development Have fun Objectives Met in CSC107 Discover how computers can solve important scientific problems Learn basics of software development Have fun

Parts of a Program Should include liberal dose of comments  2 types to help document what is going on: // This comment continues to the line’s end /* This goes until it is closed */ Also begin with preprocessor directives  Define what functions program can use #include #include #include #include #include

Symbolic Constants Code “pre-processed” before compilation  Makes code simpler & easier to read Begins #define then the name and value  Name traditionally in ALL CAPITAL letters  Can be any type and need not be literal  Must be contained on own line #define NAME “bob” #define PI #define INDIANA_PI (22.0/7.0)

Macros Symbolic constant that takes a parameter #define SQUARED(x) (x * x) #define VELOCITY(init,a,t) (init+(a*t)) #define RAND_X(x) (rand() % x) #define RAND_RNG(lo,hi) ((rand()%(hi- lo))+lo) #define MAX(x,y) ((x > y) ? x : y) Parameter replaced by value passed in  Need to be very careful about this! i = MAX(i, random()); i = ((i > rand() ? i : rand());

Pointers Pointer is another set of types  Value of pointer is another memory location  Make aliases of a variable Pointers declared with asterisk ‘*’ before variable’s name Value is a memory location  Can get variable’s memory location using &

Creating struct Declare struct outside of any function  Declared after #includes & #defines Each struct must be given a name Can have 1 or more fields  Each field has name & data type  Fields can be listed in any order  Fields declared as if it were a variable  Each struct variable gets own copy of fields

Using structs Each field has its own value  Refer to using variable.field  Fields set & used on their individually  Requires actual variable to access Each variable gets copy of every field  No relationship between fields in different variables  No relationship between different fields in one variable

Data Types Each variable also has data type  Specifies how program treats variable’s value C includes 8 built-in data types  char, short, int, long, long long, float, double, long double  Ranges for each type NOT specified; may change from machine to machine struct allows programmer-defined data type Can also have pointer or arrays of any data type

Variable Declarations Functions begin with variable declarations  Declarations must be at start of function  Function use parameters & declared variables Each declaration includes two parts 1. Type of data that variable contains 2. Name of the variable

Names in C Begin with letter or underscore (_)  Then combine letters, numbers, & underscore Names are case-sensitive  Mass, mass, & masS treated as different Function’s variables’ names must be unique  Cannot know which of my 1,000 “bob” variables to use Cannot use C’s reserved words  (p. 38 should say “int”, not “ints”)

Declaring Array Variable Declare array variable before use  Declaration must also include literal size  Variable is an array of the requested type  Locations are variables of that type int sampleArray[10]; struct person class[30]; Only creates location between 0 & size-1  Cannot find an array’s size  Will not warn when accessing beyond size

Functions At least one programmer-defined function: int main(void) Must declare & define function to use  Built-in functions automatically via “.h” files Programmer-defined functions defined outside of each other return_type function_name(parameters) { declarations; statements; }

Return Type & Parameters Function must declare a return type  Can be any data type or void When not void, must return value  return expression; ends function execution and returns result of expression Functions can have 0 or more parameters  0 parameters noted using void keyword  Else list type & name of each parameter  Separate parameters in listing by comma

Hints for Studying The exam will NOT require:  Memorizing any functions  Memorizing any code  All but most simplistic material on struct The exam WILL require:  Knowing what the built-in functions do and how to use them  How to write and use all the C constructs we discussed

Studying For the Exam 1. What does this do? Review examples and make sure you can explain the results Generate traces to verify your understanding 2. How is it used? And why is it used? 3. When do we use it? Why is it written that way?

In Conclusion… CSC107 Final Exam: Tues., Dec. 12 from 1:00–3:00 in OM 208 Bring 1 (or more) pencils for the final Do well on all your exams Have a good Christmas break Consider taking further CSC courses  We’d love to see all of you again!