CS31 Discussion 1H Fall18: week 1

Slides:



Advertisements
Similar presentations
LECTURE 1 CMSC 201. Overview Goal: Problem solving and algorithm development. Learn to program in Python. Algorithm - a set of unambiguous and ordered.
Advertisements

CSCI 1411 FUNDAMENTALS OF COMPUTING LAB Lab Introduction 1 Shane Transue MSCS.
COSC 120 Computer Programming
What Data Do We Have? Sections 2.2, 2.5 August 29, 2008.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
If You Missed Last Week Go to Click on Syllabus, review lecture 01 notes, course schedule Contact your TA ( on website) Schedule.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition by Tony Gaddis, Judy Walters,
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Class 1: What this course is about. Assignments Reading: Chapter 1, pp 1-33 Do in Class 1: –Exercises on pages 13, 14, 22, 28 To hand in in Class 2: –Exercises.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CSE 332: C++ program structure and development environment C++ Program Structure (and tools) Today we’ll talk generally about C++ development (plus a few.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
CS110/CS119 Introduction to Computing (Java)
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
CS 114 – Class 02 Topics  Computer programs  Using the compiler Assignments  Read pages for Thursday.  We will go to the lab on Thursday.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
Class 1: What this course is about. Assignment Read: Chapter 1 Read: Chapter 1 Do: Chapter 1 ‘workbook’ pages not finished in class Do: Chapter 1 ‘workbook’
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
CHAPTER 1: INTRODUCTION C++ Programming. CS 241 Course URL: Text Book: C++ How to Program, DETITEL & DEITEL, eighth Edition.
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Brief Version of Starting Out with C++ Chapter 1 Introduction to Computers and Programming.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Tutorial 1 Writing Your First C++ Program CSC1110C Introduction to Computer Programming By Paul Pun Acknowledgement: Special thanks to Dr. Michael Fung.
Introduction to CSCI 1311 Dr. Mark C. Lewis
Chapter 1: Introduction to Computers and Programming
CMPT 201 Computer Science II for Engineers
Elementary Programming Concepts Hannah Westra
Computer Engineering Department Islamic University of Gaza
Katherine Kampf / kkampf
Jie(Jay) Wang Week1 Sept. 30
Lab Introduction Installing Python
Microsoft Imagine All KU students currently enrolled in a CS class are eligible to receive Microsoft software, including Operating Systems development.
Completing the Problem-Solving Process
Testing and Debugging.
Chapter 2 Assignment and Interactive Input
Beginning C++ Programming
CS5040: Data Structures and Algorithms
CSC215 Lecture Orientation.
CS 153: Concepts of Compiler Design November 30 Class Meeting
Week 1 Gates Introduction to Information Technology cosc 010 Week 1 Gates
Course Information and Introductions
Chapter 1: Introduction to Computers and Programming
Andy Wang Operating Systems COP 4610 / CGS 5765
CSCE 206 Lab Structured Programming in C
Andy Wang Operating Systems COP 4610 / CGS 5765
Andy Wang Operating Systems COP 4610 / CGS 5765
Accelerated Introduction to Computer Science
Let’s all Repeat Together
CS150 Introduction to Computer Science 1
Andy Wang Operating Systems COP 4610 / CGS 5765
Summary of what we learned yesterday
CS150 Introduction to Computer Science 1
CS 144 Advanced C++ Programming January 24 Class Meeting
Andy Wang Operating Systems COP 4610 / CGS 5765
CS31 Discussion 1D Winter19: week 4
CS31 Discussion 1H Fall18: week 6
CS31 Discussion 1D Fall18: week 2
CSCE 206 Lab Structured Programming in C
Warmup Write a function to add two integer parameters and return the result.
CS31 Discussion 1H Fall18: week 3
CS31 Discussion 1H Winter19: week 1
ICS103 Programming in C 1: Overview of Computers And Programming
Chapter 1: Introduction to Computers and Programming
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

CS31 Discussion 1H Fall18: week 1 TA: Behnam Shahbazi bshahbazi@cs.ucla.edu Credit to former TAs: Chelsea Ju and Bo-Jhang Ho

Today’s Topic Project #1 IDE Setup and Configuration Brief C++ Introduction Run Programs on Local & Seasnet We’ll do it together Compilation Errors vs Runtime Errors vs Wrong Answer

How am I? My name is Behnam “Beh” means “best” in Persian and “nam” means “name”. 6th Year PhD student – Computer Science Dept. Research area: Text mining, NLP, Machine Learning Fan of playing sports like Soccer and Ping Pong

Resources My Office Hour & Location My Email Wednesday 8:30am – 11:30am Boelter 3256S My Email bshahbazi@cs.ucla.edu Instructor’s & other TAs’ office hours http://web.cs.ucla.edu/classes/fall18/cs31/

Grading Homework: 40% Midterm: 25% Final exam: 35% Assignments: 40% 7 projects The work should be submitted electronically Late submissions will be penalized by every second Midterm: 25%  Thursday, October 25 Thursday, November 15 Final exam: 35% Saturday, December 8 Assignments: 40%

Don’t give up!! Learning Tips Keep up with the lecture material Start early Problem solving & coding may take longer than you think Read carefully Double/Triple check the project requirements Develop incrementally Add bits of code at a time, then compile, and run. It is easier to isolate any bugs, and to understand if the code is doing what you expected Don’t give up!!

Project #1 Due 11pm Monday October 8, 2018 Read the specification carefully, don’t get a 0 in any assignment! What to submit? C++ scripts original.cpp logic_error.cpp compile_error.cpp Report in MS Word format or Plain text report.doc or report.docx or report.txt Discuss any error messages the compiler reports, and incorrect/unusual results. Compress everything into one zip file, and submit online.

IDE Configuration IDE = Integrated Development Environment A programming environment that has been packaged as an application program A graphical user interface (GUI), and a code editor A compiler A debugger A lot of different tools (energy analysis, CPU utilization, …) More on Class website http://web.cs.ucla.edu/classes/fall18/cs31/ Mac Linux Windows Xcode Command Line Terminal - Visual C++

Demo – Let’s rock! Demo Xcode Old-fashion way to write code VIM to write code Use terminal to compile code and execute binary Useful commands to know: cd, ls, pwd, mkdir, “cd ..”, … Let’s run our code on Seasnet Connect to seasnet (example): Example: ssh behnam@cs31.seas.ucla.edu ssh behnam@lnxsrv.seas.ucla.eu Copy your code on seasnet: scp PATH_TO_FILE/file.cpp behnam@cs31.seas.ucla.edu:~/Desktop

Example #1 – A simple program Make groups of two people Please just copy and paste this to your code editor and run it #include <iostream> using namespace std; int main() { cout << "Hey, this really works!" << endl; return 0; }

Example #2 – A simple interactive program Please just copy and paste this to your code editor #include <iostream> using namespace std; int main() { int num; cout << "Hey, give me a number: "; cin >> num; int numSquare = num * num; cout << "The square of this number is " << numSquare << endl; return 0; }

Details of build process What exactly is going on when I click ? The hint from Xcode (the IDE)

Details of build process What exactly is going on when I click ? The hint from Xcode (the IDE) Source code Executable or Binary Run the program

Details of build process What exactly is going on when I click ? The hint from Xcode (the IDE) Compile (Build) Execute a program Source code Executable or Binary Run the program

Demo how to write a program using a terminal (Linux environment) Demo time

Why do we need to compile a program? Compile the source code by a compiler Source code (human readable) Executable/binary (machine readable)

What is C++? Is a (programming) language so that you can create a valid computer program C++ C++ C Assembly Machine code (Binary)

What is C++? Is a (programming) language so that you can create a valid computer program C++ C++ C Assembly Machine code (Binary)

What is C++? Is a (programming) language so that you can create a valid computer program C++ Object-oriented language C++ Procedural language C Assembly Machine code (Binary)

Let’s make some errors - 3 types of errors Compilation error Syntax error Undeclared identifier Common function undeclared Program crashes (Segmentation fault) The program runs into an invalid state Incorrect memory access Runtime error Logic error Wrong answer

The skeleton C++ code This is the only time in this quarter I ask you to memorize codes!! #include <iostream> using namespace std; int main() { return 0; } Let’s go through some examples

Example #3 – Another interactive program What is cin and cout? #include <iostream> using namespace std; int main() { int i, j; cout << "Please enter the value for i: " << endl; cin >> i; cout << "Please enter the value for j: " << endl; cin >> j; cout << "i + j = " << i + j << endl; return 0; }

Example #3 – Another interactive program (Cont’d) Potential errors you can get: Unbalanced bracket Missing semicolon Undefined variable Undefined operator No number after return keyword Library doesn’t exist Etc.

Example #4 – Division Any errors we may get? #include <iostream> using namespace std; int main() { int i, j; cout << "Please enter the value for i: " << endl; cin >> i; cout << "Please enter the value for j: " << endl; cin >> j; cout << "i / j = " << i / j << endl; return 0; } Any errors we may get?

Example #5 – What’s wrong with this code? #include <iostream> using namespace std; int main() int a = 10; cout << A << endl; return 0; } Paste it to your programming editor to find the answers

Example #6 – Access invalid index in an array (advanced) #include <iostream> using namespace std; int main() { int arr[100]; arr[-99999999] = 3; return 0; } Since there are only 100 available spots whose index ranged from 0 to 99, write back to any other index beyond this range will screw the memory and may crash the program

For project 1 – generate some bugs You may want to explore the language a little bit… If Array For loop / while loop