CS 101: Computer Programming and Utilization. Abhiram Ranade

Similar documents
CS 101: Computer Programming

CS Semester I. Quiz 1 (version A)

An approach to introductory programming

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4

Pre- Defined Func-ons in C++ Review for Midterm #1

Unit 10: Data Structures CS 101, Fall 2018

Lecture 1. Introduction to course, Welcome to Engineering, What is Programming and Why is this the first thing being covered in Engineering?

Art, Nature, and Patterns Introduction

Self-Teach Exercises: Getting Started Turtle Python

: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics

PIC 10A. Review for Midterm I

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

Geometry Worksheet Organizing Quadrilateral Properties Answers

Design and Debug: Essen.al Concepts CS 16: Solving Problems with Computers I Lecture #8

Finding Pi: Applications of Loops, Random Numbers, Booleans CS 8: Introduction to Computer Science, Winter 2018 Lecture #6

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Computer and Programming: Lab 1

Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6

Week 3: Objects, Input and Processing

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

MATH 1131Q - Calculus 1.

Welcome to Solving Problems with Computers I

Math CC 7: Shapes & Designs Inv. 2 Name: Per:

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims

Course Administration

Lecture 1. Course Overview Types & Expressions

CMPT-101. CMPT-101-D2, Spring Course Web Page Course Mailing List. Exams. Assignments

Skill 1: Multiplying Polynomials

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

Pre Calc Application Word Problems For Trig

Tutorials. Tutorial every Friday at 11:30 AM in Toldo 204 * discuss the next lab assignment

Introduction to Computer Systems

Calculus (Math 1A) Lecture 1

PRE-ALGEBRA PREP. Textbook: The University of Chicago School Mathematics Project. Transition Mathematics, Second Edition, Prentice-Hall, Inc., 2002.

Call-by-Type Functions in C++ Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #5

Module 10A Lecture - 20 What is a function? Why use functions Example: power (base, n)

ENGR 105: Introduction to Scientific Computing. Dr. Graham. E. Wabiszewski

Understanding the Screen

Welcome to CS 135 (Winter 2018)

AMS 27L LAB #1 Winter 2009

CSci 4211: Data Communications and Computer Networks. Time: Monday and Wednesday 1 pm to 2:15 pm Location: Vincent Hall 16 Spring 2016, 3 Credits

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

} Each object in a Java program has an identifier (name) } This includes:

C++ Programming Lecture 11 Functions Part I

CSC 111 Introduction to Computer Science (Section C)

Scientific Computing

ESET 369 Embedded Systems Software, Fall 2017

CS3: Introduction to Symbolic Programming. Lecture 5:

Junior Circle Meeting 9 Commutativity and Inverses. May 30, We are going to examine different ways to transform the square below:

Computer Science & Engineering 150A Problem Solving Using Computers

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #33 Pointer Arithmetic

Numerical Analysis First Term Dr. Selcuk CANKURT

CS 106B, Lecture 1 Introduction to C++

Mathematics Background

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 3. Existing Information. Notes. Notes. Notes. Lecture 03 - Functions

Use Parametric notation. Interpret the effect that T has on the graph as motion.

More Examples Using Functions and Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #6

4. Write sets of directions for how to check for direct variation. How to check for direct variation by analyzing the graph :

Properties of Triangles

College Algebra. Cartesian Coordinates and Graphs. Dr. Nguyen August 22, Department of Mathematics UK

CS 4349 Lecture August 21st, 2017

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

Math 20A lecture 10 The Gradient Vector

Activity Guide APIs and Using Functions with Parameters

Numerical Conversions Intro to Strings in C/C++ CS 16: Solving Problems with Computers I Lecture #8

Turtle Graphics and L-systems Informatics 1 Functional Programming: Tutorial 7

WORKBOOK 10 ACTION GEOMETRY SQUARE AND PENTAGON

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

: Dimension. Lecturer: Barwick. Wednesday 03 February 2016

Direct Variations DIRECT AND INVERSE VARIATIONS 19. Name

CS 241 Computer Programming. Introduction. Teacher Assistant. Hadeel Al-Ateeq

WELCOME TO CS 16! Problem Solving with Computers-I

MSO Lecture 1. Wouter Swierstra (adapted by HP) September 11, 2017

CSCI-1200 Data Structures Fall 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic

Introduction to C++ Dr M.S. Colclough, research fellows, pgtas

EP241 Computer Programming

Midterms Save the Dates!

CSci 4211: Introduction to Computer Networks. Time: Monday and Wednesday 2:30 to 3:45 pm Location: Smith Hall 231 Fall 2018, 3 Credits

CS1 Lecture 4 Jan. 23, 2019

Computer Programming

(Refer Slide Time: 1:43)

SAMS Programming A/B. Lecture #1 Introductions July 3, Mark Stehlik

CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall Office hours:

ESET 349 Microcontroller Architecture, Fall 2018

CSE 167: Lecture #15: Procedural Modeling. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

61A Lecture 4. Monday, September 9

ENCM 335 Fall 2018 Lab 2 for the Week of September 24

CSCE 441 Computer Graphics Fall 2018

LESSON 1: Trigonometry Pre-test

PIC 10A. Lecture 3: More About Variables, Arithmetic, Casting, Assignment

2 Making Decisions. Store the value 3 in memory location y

General course information

CSC116: Introduction to Computing - Java

MCOM 6336 Digital Media Spring 2014

Course Information and Introduction

CSCD18: Computer Graphics. Instructor: Leonid Sigal

Introduction to Computer Systems

Chapter 7. Polygons, Circles, Stars and Stuff

File I/O in Python CS 8: Introduction to Computer Science Lecture #11

Transcription:

CS 101: Computer Programming and Utilization Abhiram Ranade

CS 101: Computer Programming and Utilization Abhiram Ranade

Course Overview How to represent problems on a computer and solve them Programming examples to be drawn from CSE, Mathematics, Engineering, and anything fun! C++ programming language No prior knowledge necessary.

Course Resources Textbook: Introduction to Problem Solving and Programming Through C++ (draft) on moodle Lecture slides: www.cse.iitb.ac.in/~cs101/... Other resources: www.cplusplus.com Previous years' course pages. Teaching Assistants, and me!

Grading 12 % : Quiz 1, Friday 31/8, 8:30-9:30 am 25 % : Midterm 12 % : Quiz 2, Friday 26/10, 8:30-9:30 am 35 % : Final Examination 8 % : Lab assignments 8 % : Lab Project

Teachers Lecturer: Abhiram Ranade. 12 Senior Teaching Assistants (Mtech 2) 6 lab supervisors 6 other duties 48+ Junior Teaching Assistants. (Mtech 1) Lab consultants

Lectures Students divided into 4 divisions. Each lecture first to Divisions 1,2, and again to Divisions 3,4. Div 1,2: Slot 11A,11B. Tu, Fr 3:30-4:55 Div 3,4: Slots 5A, 5B We, Fr 9:30-10:55 Venue: Hall 1, Lecture Hall Complex.

Tutorials Div 1, 2: X3: Wednesday 3:30-4:25 Div 3, 4: 4C: Thursday 9:30-10:25 Venue: Hall 1. Tutorial = Clearing of doubts. You must ask. Tutorial = Will be used for lectures if holidays cause batches to go out of sync. Keep Free!!

Labs (6 batches) Batch 1: Tuesday 9:30-11:30 CSE Batch 2: Tuesday 8:30-10:30: Ch BTech + MSc MA+ASI Batches 3-6: W,Th,Fr,M 8:30 pm -10:30 pm You will receive mail Venue: Old Software Lab (OSL). Ground floor of Math Building (Next to Library).

Lab Assignments Announced before the session. You may discuss assignment, but code individually. Lab assignments are meant more for you to practice than for us to grade you. This week: how to log in, how to use an editor to write a program, how to compile the program and run it. General information about Unix.

C++ programming language Designed by Bjarne Stroustrup, 1980s. Derived from C programming language. Substantial evolution. Still continues. Early part of the course: C++ augmented with a package called simplecpp Simplecpp: easier to use than bare C++. More fun. Built-in graphics.

Today's topic Use Turtle Simulator contained in simplecpp Inspired by LOGO programming language You can drive around the turtle. Turtle has a pen, so it draws as it moves. To drive the turtle you write a simple C++ program.

Turtle Simulator Turtle = small red triangle of the screen. Turtle commands: forward, right, left Turtle has pen touching the ground. Picture drawn as turtle moves! Your goal: drive the turtle around and draw nice pictures.

C++ Program to draw a square #include <simplecpp> main_program{ turtlesim(); forward(10); right(90); forward(10); right(90); forward(10); right(90); forward(10); wait(5); closeturtlesim(); }

Explanation #include <simplecpp> : I am using simplecpp main_program{..your program goes here.. } turtlesim() : open a window, turtle at the center. forward(100) : move turtle forward by 100 pixels. right(90) : turn right 90. Similarly left. wait(5): do nothing for 5 seconds. closeturtlesim(): close window.

How to run this program Log in to an OSL computer. Open an editor and type in the program call it square.cpp Compile it: s++ square.cpp Run it./a.out

General Ideas C++ program = sequence of commands/statements inside main_program{ } Statement/command: terminated by ; Arguments: additional data needed by command to do its work. forward(argument): how much forward? right(argument): what angle? () if no arguments, e.g. turtlesim()

General Ideas (contd) {} () [] are all different. Case is important Main_program is different from main_program.

How to draw a square 2 #include <simplecpp> main_program{ turtlesim(); repeat(4){ forward(10); right(90); } wait(10); closeturtlesim(); }

Repeat Statement repeat (x) {... } : execute x times whatever is inside { }.

How to draw a polygon main_program{ turtlesim(); cout << How many sides? ; int nsides; cin >> nsides; repeat(nsides){ forward(10); right(360.0/nsides); } wait(10); closeturtlesim(); }

Explanation of statements int nsides; : Reserve a cell for me in memory in which I will store some integer value, and call that cell nsides. cout <<... : Print that message on the screen. cin >> nsides; Read an integer value from the keyboard and put it in the cell nsides. nside: Variable taking integer values. Can be used wherever numbers may appear.

Some useful commands penup(): Causes the pen to be raised. pendown(): Causes the pen to be lowered. sqrt(x) : square root of x. sine(x), cosine(x), tangent(x) : trigonometric functions, x is in degrees. sin(x), cos(x), tan(x) : x is in radians.

Repeat within repeat repeat(4){ repeat(3){ right(90); forward(10); penup(); forward(10); pendown(); } }

Summary 1 Control flow: execution starts at top and goes down. Retraced if there is a repeat statement. Variables: used for storing data. Think of a variable as a box which contains a slip of paper on which a value is written. Wherever ordinary numbers can be given, we can give variables, or expressions involving variables.

Summary 2 Commands: You can use them without worrying about how exactly they do their work. Symmetry/repetitive pattern in picture is matched by repeat statement.

Spirit of the course 1 Learn C++ statements. We have covered a lot of ground today, even if it doesn t seem so. Learn how to express problems you want to solve using C++. Drawing pictures. Will need interesting geometric calculation. Solving math problems, e.g. Finding roots, curve fitting,..... Goal 1: if you can solve a problem by manual calculation, possibly taking an enormous amount of time, by the end of the course, you should be able to write a program for it. Goal 2: Learn new ways of solving problems!

Spirit of the course 2 Do not be afraid of using the computer. What if I write xyz in my program instead of pqr? : Just do so and find out. Be adventurous. Exercise your knowledge by writing programs that is the real test.

Homework Read chapter 1. Draw a 5 pointed star. Draw a 7 pointed star. How many different 7 pointed stars can you have? Draw 7 identical circles, with 6 touching the central circle. Circle = polygon of large no of sides, say 360. Draw 4x4 array of tiles slightly separated from each other.