CSC 107 – Programming For Science. History of C  Dennis Ritchie developed C from 1969 – 1973  While at Bell Labs, created language to develop Unix 

Slides:



Advertisements
Similar presentations
C++ Introduction.
Advertisements

C Language.
XHTML Basics.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Three types of computer languages
1 ICS103 Programming in C Lecture 2: Introduction to C (1)
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
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.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
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.
Chapter 3 Getting Started with C++
CSC 107 – Programming For Science. Today’s Goal ALL  Understand why ALL I/O is file I/O  Common bugs to avoid when coding with files in C++  Get a.
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.
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.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
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 &
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Announcements  If you need more review of Java…  I have lots of good resources – talk to me  Use “Additional Help” link on webpage.
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.
CIT 590 Intro to Programming First lecture on Java.
PHY 107 – Programming For Science. History of C  Dennis Ritchie developed C from 1969 – 1973  Based upon B (& other) earlier languages  Since its creation,
Sharda University P. K. Mishra (Asst.Prof) Department of Computer Science & Technology Subject Name: Programming Using C Sub Code: CSE-106 Programming.
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.
Introduction to programming in the Java programming language.
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. Announcement Today’s Goal  Know how to write selections besides if-else  Why we use select or if - else and how.
CSC 212 – Data Structures Prof. Matthew Hertz WTC 207D /
C programming language was developed in the seventies by a group of at the Bell Telephone lab. The C language was the outline of two earlier languages.
Chapter 2 part #1 C++ Program Structure
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 107 – Programming For Science. Announcements.
CSC Programming for Science Lecture 4: Beginning Programming.
CSC Programming for Science Lecture 10: Boolean Expressions & More If ­ Else Statements.
CPS120: Introduction to Computer Science Introduction to C++
CRE Programming Club - Class 2 Robert Eckstein and Robert Heard.
CSC 107 – Programming For Science. Today’s Goal  Know how to write selections besides if-else  When each of the options makes sense  When each selection.
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. Announcements no magic formulas exist  Need to learn concepts: no magic formulas exist  Single solution not useful;
CSC 107 – Programming For Science. Announcements  Lectures may not cover all material from book  Material that is most difficult or challenging is focus.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
LECTURE 22: BIG-OH COMPLEXITY CSC 212 – Data Structures.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Problem of the Day  Why are manhole covers round?
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
CSC 107 – Programming For Science. Today’s Goal  Write functions that take & return values  How parameters declared and how we call functions  What.
CSC Programming for Science Lecture 5: Actual Programming.
A Python Tour: Just a Brief Introduction
User-Written Functions
Structured Programming
Chapter 2 part #1 C++ Program Structure
Getting Started with C.
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C Programming Language
Mr. Shaikh Amjad R. Asst. Prof in Dept. of Computer Sci. Mrs. K. S
Programming 1 (CS112) Dr. Mohamed Mostafa Zayed 1.
Govt. Polytechnic,Dhangar
Introduction to C++ Programming
Programming Introduction to C++.
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

CSC 107 – Programming For Science

History of C  Dennis Ritchie developed C from 1969 – 1973  While at Bell Labs, created language to develop Unix  Based upon B, an earlier programming language (Also used other, less funny, languages)

History of C  Popular since 1978 book by Kernighan & Ritchie  Language grown organically since its creation  Companies often add own features beyond standards

History of C++  Created by Bjarne Stroustrup to add objects to C  Immediately added other features to improve C  In 1983, renamed as C++ to show all the changes  Name is an inside joke: "++" is increment operator  Book published soon after in '85  Updated for quick growth  2.0 release in 1989  1998 adopted as ISO standard  C x in development now

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 standard of C added most C++ features  But classes & objects still not part of C language  For this reason, also not a part of CSC 107  C++ compiles almost all C programs natively  Differences are minimal and easily avoided  C++ is “looser C” once objects are removed  Several annoying restrictions removed from C  Often supported in C anyway, since make life easier

 Computers have no common-sense do what you tell them to do  They will only do what you tell them to do  NOT what you want them to do  NOT what you want them to do, which often differs

Case-Sensitivity  Example of computers being very literal  And language not helping by fixing what you say  main, Main, & MAiN treated as different words  Case of the letters matters, not just the words  Could be different, so 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++ actually helps you  C++ treats whitespace equally – spaces, enters, & tabs  Does not matter if there is none, 1, or  Whitespace cannot be within a symbol  “ : : ” and “ :: ” are treated differently  One or more blanks between words needed  Wecansplitwordsbutthecomputercannot

“Whitespace”  One (very small) way C++ actually helps you  C++ treats whitespace equally – spaces, enters, & tabs  Does not matter if there is none, 1, or  Whitespace cannot be within a symbol  “ : : ” and “ :: ” are treated differently  One or more blanks between words needed  Wecansplitwordsbutthecomputercannot

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

#include Statements #include using std::cout; /* Hi, Mom. This is a comment that goes over 2 line. */ int main() { std::cout << “Hello world!”; return 0; // This comment goes to the line’s end }  Nearly every C++ file begins with this directive  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 using std::cout; /* Hi, Mom. This is a comment that goes over 2 line. */ int main() { std::cout << “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 using std::cout; /* Hi, Mom. This is a comment that goes over 2 line. */ int main() { std::cout << “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 using std::cout; int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ std::cout << “Hello world!”; return 0; // This comment goes to the line’s end }

Using Commands #include using std::cout; /* Hi, Mom. This is a comment that goes over 2 line. */ int main() { std::cout << “Hello world!”; return 0; // This comment goes to the line’s end }  More “magic”, but using has less important purpose  Tells compiler to make shortcut & save some typing  Two types of using statements to choose from  Specify single shortcut with using std::cout  using std; gives you a list of shortcuts to use  Unlike #include statements, using never required  Do not worry about it – will not be using them

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

main Function #include using std::cout; int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ std::cout << “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 using std::cout; int main() { /* Hi, Mom. This is a comment that goes over 2 line. */ std::cout << “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 screiben  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++  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  Get in groups of 3 & work on following activity

For Next Lecture  Read sections 4.1 – 4.10 in book for Monday  What is a data type?  What are variables?  How can we use variables in a program?  How are literal, constant, & variable different?  Week #1 weekly assignment due Tuesday  Problems available on Angel – covered 1 st two already  If problem takes more than 10 minutes, TALK TO ME!