CS50 Section 2 21 September 2015 Sam Green ’17 (646) 457 - 2340.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Parameter passing mechanism: pass-by-reference. The Pass-by-reference mechanism - the agreement Recall: Parameter passing mechanism = agreement between.
Functions Prototypes, parameter passing, return values, activation frams.
CS110 Programming Language I
Computer Science 2 Data Structures V section 2 Recitation 1.
Programming in C Pointers and Arrays. 1/14/102 Pointers and Arrays In C, there is a strong relationship between pointers and arrays.In C, there is a strong.
1 Lecture13: Other C Topics 12/17/2012. Topics Variable-length argument lists Pointers to functions Command-line arguments Suffixes for integer and floating-point.
A file reminder Files are used to store data and information They are manipulated through a pointer to FILE (FILE *) This pointer is returned when opening.
Stack buffer overflow.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
CMPE13 Cyrus Bazeghi Hands on with Functions and IO.
Command-line arguments CS 201 Fundamental Structures of Computer Science.
CS1061: C Programming Lecture 23: Review; Examination Details A. O’Riordan, 2005.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
Introduction to Computers and Programming Class 22 Character Arrays (Strings) Professor Avi Rosenfeld.
Programming Review: Functions, pointers and strings.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Exercise 10 Review: pointers, strings and recursion.
CS1061 C Programming Lecture 15: More on Characters and Strings A. O’Riordan, 2004.
CS 240: Data Structures Supplemental: Command Line Input.
Programming in C Pointers and Arrays. 1/14/102 Pointers and Arrays In C, there is a strong relationship between pointers and arrays.In C, there is a strong.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Characters and Strings Literals and Variables Dale Roberts,
Computer Science 210 Computer Organization Strings in C.
Command line arguments. – main can take two arguments conventionally called argc and argv. – Information regarding command line arguments are passed to.
Cryptography Programming Lab
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 15: Linked data structures.
More on Functions (Part 2) Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Agenda Review C++ Library Functions Review User Input Making your own functions Exam #1 Next Week Reading: Chapter 3.
CS50 Week 2. RESOURCES Office hours ( Lecture videos, slides, source code, and notes (
Course Introduction Bryce Boe 2013/09/30 CS24, Fall 2013.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Command Line Arguments.
1 Command-Line Processing In many operating systems, command-line options are allowed to input parameters to the program SomeProgram Param1 Param2 Param3.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
1 CS161 Introduction to Computer Science Topic #17.
Weeks 5-6 Pointers and Arrays Basic pointer type Pointers and Arrays Address arithmetic Pointer Arrays User-defined data types Structures Unions Pointers.
CSE 232: C++ memory management Overview of Arrays Arrays are the simplest kind of data structure –One item right after another in memory (“contiguous range”
© M. Gross, ETH Zürich, 2014 Informatik I für D-MAVT (FS 2014) Exercise 4 – Logical Operators & Branching.
Strings Programming Applications. Strings in C C stores a string in a block of memory. The string is terminated by the \0 character:
Nonvisual Arrays by Chris Brown under Prof. Susan Rodger Duke University June 2012.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
Cryptography.
Fall 2004CS-183 Dr. Mark L. Hornick 1 C++ Arrays C++ (like Java) supports the concept of collections – mechanisms to sort and manipulate many instances.
Jeopardy Print Me Which loop? Call Me Name Me My Mistake Q $100 Q $200 Q $300 Q $400 Q $500 Q $100 Q $200 Q $300 Q $400 Q $500 Final Jeopardy.
Characters and Strings
1 11/30/05CS150 Introduction to Computer Science 1 Structs.
Programming in C Pointers and Arrays. 1/14/102 Pointers and Arrays In C, there is a strong relationship between pointers and arrays.In C, there is a strong.
CSE 232: Moving Data Within a C++ Program Moving Data Within a C++ Program Input –Getting data from the command line (we’ve looked at this) –Getting data.
C Tutorial - Pointers CS 537 – Introduction to Operating Systems.
Week 6 - Friday.  What did we talk about last time?  Pointers  Passing values by reference.
Q and A for Sections 2.9, 4.1 Victor Norman CS106 Fall 2015.
Characters and Strings
Command Line Arguments
Command line arguments
Command Line Arguments
Understand argc and argv
More Examples of argc and argv
Command-line Arguments
Command Line Arguments
Computer Science 210 Computer Organization
Command-line arguments
sscanf()- string scan function
Command Line Parameters
Command-line arguments
Strings and Pointer Arrays
ECE 103 Engineering Programming Chapter 46 argc, argv, envp
Programming in C Pointers and Arrays.
Unit-1 Introduction to Java
Presentation transcript:

CS50 Section 2 21 September 2015 Sam Green ’17 (646)

Agenda Intros Norms and Expectations Arrays Functions Command-Line Arguments Problem Set Review

Introduction Sam Green Junior (2017) Cabot House (quad life!) Computer Science & Statistics joint concentrator. Returning TF to CS50 Former member of the heavyweight crew team, now enjoying a life of freedom.

Norms & Expectations From me: Support Availability High expectations Clear feedback From you: Meeting in the middle Reading the pset spec before section Reading comments on your problem sets! Participate

Warmup (1) Write a program to print “SLG” on 10 times.

Warmup (2) What is a data type? What is typecasting? Convert to decimal (what’s decimal?) Any other questions?

Arrays (1) Structure: ] Examples: char alpha[26] int score[5]

Arrays (2) “Initialize” aka set up in two ways: int score[2]; score[0] = 0; score[1] = 1; or: int score[] = {1,2,3,4,5};

Arrays (3) We can “index into” akas access an array using: int score[] = {1,2,3,4,5}; int num = score[3];

Exercise: Arrays (1) Write a program that creates an array of strings, and then prints out the array’s members each on its own line.

Exercise: Arrays (2) a) Write a program that creates an int array of size 10, fills it with the numbers 10-19, and then prints these out. b) Now change it to a string and print out each character!

Functions (1)Take Something In (2) Do Something (3)Spit out an answer aka “return a value” Why functions?

Functions (2) Important things to know: Return types Name of functions Parameter types Prototypes Scope

Exercise: Functions (1) Write a function that takes in a string “name” from the user and prints out “Hi, this is my first function.”

Exercise: Functions (2) Write a program with a function

Command-Line Arguments Command Line Arguments are passed into the main function of the program when it runs. int main(int argc, string argv[]) What is argv[]? What is argc?

Exercise: command-line arguments (1) Write a program that prints out the program’s name. (2) Write a program that prints out the first character of every command line argument passed to it.

Exercise: Synthesis Write a program that calls 1 function if the command line argument “one” is passed in, calls another function if the command line argument “two” is passed in, and does nothing otherwise. The functions can do whatever you want!

Review of Today Arrays Functions Command-line Arguments Questions?

PSet Review Initials Caesar – atoi function – Tips: start by writing a program that rotates each letter by one, and then change it to the full cipher. Vigenere’ – Start with your Caesar program and notice the similarities. Every week has the same hint: tackle the problem sets in small steps!