PHY 107 – Programming For Science. History of C  Dennis Ritchie developed C from 1969 – 1973  Based upon B (& other) earlier languages  Since its creation,

Slides:



Advertisements
Similar presentations
C Language.
Advertisements

Practice Quiz Question
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Lesson 13 PROTECTING AND SHARING DOCUMENTS
Important concepts in software engineering The tools to make it easy to apply common sense!
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
CSC 395 – Software Engineering Lecture 21: Overview of the Term & What Goes in a Data Dictionary.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Programming Introduction to C++.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
Introduction to C++ Programming Introduction to C++ l C is a programming language developed in the 1970's alongside the UNIX operating system. l C provides.
Introduction to Python
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
CSC 107 – Programming For Science. Announcements.
CSC 107 – Programming For Science. Announcements  Tutors available MTWR in WTC206/WTC208  Special lab (with Macs) & not in the Tutoring Center  Can.
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
CSC 107 – Programming For Science. Announcements  Textbook available from library’s closed reserve.
CSC 107 – Programming For Science. Spacing in a Program  C++ ignores spaces in a program  This also means where newlines placed ignored  #define &
Visual Basic.NET BASICS Lesson 4 Mathematical Operators.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage.
March 16 & 21, Csci 2111: Data and File Structures Week 9, Lectures 1 & 2 Indexed Sequential File Access and Prefix B+ Trees.
CSC 107 – Programming For Science. History of C  Dennis Ritchie developed C from 1969 – 1973  Based upon B (& other) earlier languages  Since its creation,
Problem of the Day  Why are manhole covers round?
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
Introduction to C++ // Program description #include directives int main() { constant declarations variable declarations executable statements return.
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
5 BASIC CONCEPTS OF ANY PROGRAMMING LANGUAGE Let’s get started …
Chapter 7 File I/O 1. File, Record & Field 2 The file is just a chunk of disk space set aside for data and given a name. The computer has no idea what.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
CSC 107 – Programming For Science. Announcements.
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. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
CSC 107 – Programming For Science. The Week’s Goal.
CSC 107 – Programming For Science. Announcements  Locations of Macs to use outside of lab time  Can find on Library ground floor (6) & main floor (6)
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
CSC 107 – Programming For Science. History of C  Dennis Ritchie developed C from 1969 – 1973  While at Bell Labs, created language to develop Unix 
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
CSC 212 – Data Structures Prof. Matthew Hertz WTC 207D /
Question of the Day You overhear a boy & his mother talking: Mom:What is ? Boy: That's easy, 33. Mom: Good. What's ? Boy:Simple. It's 40. Mom:Excellent!
CSC 107 – Programming For Science. Today’s Goal  Discuss writing functions that return values  return statement’s meaning and how it works  When and.
CSC Programming for Science Lecture 4: Beginning Programming.
CSC Programming for Science Lecture 10: Boolean Expressions & More If ­ Else Statements.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
CRE Programming Club - Class 2 Robert Eckstein and Robert Heard.
A Python Tour: Just a Brief Introduction "The only way to learn a new programming language is by writing programs in it." -- B. Kernighan and D. Ritchie.
PHY 107 – Programming For Science. Today’s Goal  Discuss how to hand data to functions  Review loopholes in variables & scoping rules  Ways to get.
PHY 107 – Programming For Science. Announcements no magic formulas exist  Need to learn concepts: no magic formulas exist  Single solution not useful;
CSC Programming for Science Lecture 37 : Course Review.
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.
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
CSC 212 – Data Structures Lecture 15: Big-Oh Notation.
LECTURE 22: BIG-OH COMPLEXITY CSC 212 – Data Structures.
Problem of the Day  Why are manhole covers round?
CSC 107 – Programming For Science. Today’s Goal  Write functions that take & return values  How parameters declared and how we call functions  What.
JavaScript Part 1 Introduction to scripting The ‘alert’ function.
Lesson 13 PROTECTING AND SHARING DOCUMENTS
Lecture 3: Getting Started & Input / Output (I/O)
Bill Tucker Austin Community College COSC 1315
User-Written Functions
Getting Started with C.
Lesson 13 PROTECTING AND SHARING DOCUMENTS
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Debugging with Eclipse
Introduction to Python
File Handling Programming Guides.
Programming 1 (CS112) Dr. Mohamed Mostafa Zayed 1.
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
Programming Introduction to C++.
Debugging with Eclipse
Presentation transcript:

PHY 107 – Programming For Science

History of C  Dennis Ritchie developed C from 1969 – 1973  Based upon B (& other) earlier languages  Since its creation, language grown organically  Tradition of adding features beyond standard as desired

History of C++  Bjarne Stroustrup created to add “objects”  Also included many other improvements to language  Name is inside joke: "++" increases value by 1 in C  Updated for quick growth  ISO standard adopted in 1998  Recently updated to C x

C Versus C++ C++ is designed to be as compatible with C as possible, thereby providing a smooth transition from C

C Versus C++ C++ C

C Versus C++ C

 Latest definition of C added most C++ features  Classes & objects excepted, these only found in C++  For this reason, also not a part of PHY 107  Differences now minimal and easily avoided  Once objects removed, C++ just “looser” C  Removes annoying restrictions that had been in C  Since makes life easier, often supported in C anyway

Case-Sensitivity  Example of computers being very literal  And language not helping by fixing what you say  main, Main, & MAiN treated as totally different  Case of the letters matters, not just the words  Might want difference; C won’t change Main to main  Can help prevent easy mistakes from swapping names  With just a little practice, becomes second nature

“Whitespace”  One (very small) way C/C++ actually helps you  Treats all whitespace equally – spaces, enters, & tabs  Whether 1 or – all will be ignored  Cannot use in symbol, whitespace splits words  Treats these as different “ : : ” and “ :: ”  Spaces between words needed, but not counted  Wecansplitwordsbutthecomputercannot

“Whitespace”  One (very small) way C/C++ actually helps you  Treats all whitespace equally – spaces, enters, & tabs  Whether 1 or – all will be ignored  Cannot use in symbol, whitespace splits words  Treats these as different “ : : ” and “ :: ”  Spaces between words needed, but not counted  Wecansplitwordsbutthecomputercannot

Your First C Program #include #include int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ printf(“Hello world!”); return 0; // This comment goes to the line’s end }

#include Statements #include #include int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ printf(“Hello world!”); return 0; // This comment goes to the line’s end }  Nearly every C file begins with these lines  May add more #include to include other files  Contents of included file usable as if it were here  Easy way to copy ideas across multiple files  Programs can use two types of #include statements  Include system file using #include  #include “ filename ” includes a file you wrote

Watch Me Pull a Rabbit #include #include int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ printf(“Hello world!”); return 0; // This comment goes to the line’s end }  For now, automatically start each file with this line  Details are unimportant – consider it magic

Watch Me Pull a Rabbit #include #include int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ printf(“Hello world!”); return 0; // This comment goes to the line’s end }  For now, automatically start each file with this line  Details are unimportant – consider it magic

Your First C Program #include #include int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ printf(“Hello world!”); return 0; // This comment goes to the line’s end }

main Function #include #include int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ printf(“Hello world!”); return 0; // This comment goes to the line’s end }  All C++ programs contain function called main  Tells computer where to start running program  Code inside the braces will be what is executed  For the moment, consider this more “magic”

main Function #include #include int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ printf(“Hello world!”); return 0; // This comment goes to the line’s end }  All C++ programs contain function called main  Tells computer where to start running program  Code inside the braces will be what is executed  For the moment, consider this more “magic”

Comments  Vital  Vital for writing and maintaining any program  Not required to run program - only for human eyes  Computer simply ignores anything in a comment  Use to describe code in simple English  Sie konnen auch auf Deutsch schreiben  o U c%d wrte n txt msg  Should be used liberally  I add comments where cannot see what code does  Impossible to have too many comments, if readable

Comments in C/C++  Double slash comments continue to line’s end a = a – 4; // Hi, Mom! // This entire line is a comment!  /* … */ comments can be on one or more lines a = a - /* Hi, Mom! */ 4; /* This comment takes an entire line. */ /* This is a really long comment that * goes on to multiple lines. The stars on * lines 2 and on are optional, but * makes things easier to read. */

Your Turn  Work on activity in groups until 11:45  Each group will submit 1 copy at end  Professor chooses the copy; so must work together

For Next Lecture  Will have lab tomorrow, so bring flash drive  Have not done much, but we can start to see system  Read pages 34-37, 57-59, for Friday  What is a data type?  What are variables?  How do variables differ from numbers and letters?  Week #1 assignment on D2L & due Tuesday relies on tomorrow’s lab  This week different – relies on tomorrow’s lab