CS 101 Introduction to computer programming and utilization

Reviews
CS 101: Introduction to 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 Not much on hardware.    Course Resources  Textbook: Cohoon & Davidson, C++ Program Design. Lecture slides on course homepage: www.cse.iitb.ac.in/~cs101 Other resources from the web Previous years' course pages. Teaching Assistants, and me!     Grading  10 % : Quiz 1 25 % : Midterm   10 % : Quiz 2 40 % : Final Examination   7 % : Lab assignments 8 % : Lab Project  Teachers  Lecturer: Abhiram Ranade. 10 Senior Teaching Assistants (Mtech 2)‫‏‬    5 lab supervisors 5 other duties  55 Junior Teaching Assistants. (Mtech 1)‫‏‬   40 lab supervisors 15 Consultants Lectures  Students divided into 4 divisions. Each lecture first to Divisions 1,2, and again to Divisions 3,4. Div 1,2: Slot 3A,3B.   Mon 10:30-11:30, Tue: 11:30-12:30  Div 3,4: Slots 2A, 2C  Mon 9:30-10:30, Thu: 11:30-12:30  Venue: PC Saxena Auditorium Lab  10 batches, each with about 70 students. 6:30-8:30 Monday 1 8:30-10:30 2 Tuesday Wednesday 3 5 4 6 Thursday Friday 7 9 8 10 Which batch are you in?  You will receive an e-mail telling you which batch you are in.  Please check your e-mail. Labs Begin This Week  Venue:‫“‏‬Old‫‏‬Software‫‏‬Lab”,‫‏‬Ground‫‏‬Floor‫‏‬of‫‏‬ Math Building. Show up at your batch time. Lab will be conducted by 1 senior TA and 4 Junior TAs.    Each junior TA will grade the work of 1/4th of each batch, called a section. Sections: find out in the first session.  Lab Assignments  Assignment for this week: handout will be given when you go to the lab  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 Lab assignments are meant more for you to practice than for us to grade you. This‫‏‬week’s‫‏‬assignment  Use‫‏‬a‫“‏‬Turtle‫‏‬Simulator”‫‏‬developed‫‏‬by‫‏‬your‫‏‬ TAs. 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. It is easy, you will all be driving your turtles in no time!     Program to draw a square procedure turtleMain(){ forward(10); right(90); forward(10); right(90); forward(10); right(90); forward(10); } Procedures and Procedure Calls  turtleMain : Procedure you wrote. The simulator will execute this procedure after it sets up the the window on the screen etc.  forward(10) : procedure you are asking to execute, “procedure‫‏‬you‫‏‬called”. Other numbers can be given instead of 10. Turtle moves forwards that many steps. right(90): turn right 90˚. Another procedure.   How to run this program  Log in to an OSL computer. Open an editor and type in the program call it turtle1.cpp Compile it.    Run it Click‫‏‬the‫“‏‬X”‫‏‬to‫‏‬remove‫‏‬the‫‏‬picture.  How to draw a square 2 procedure turtleMain(){ repeat(4){ forward(10); right(90); } } How to draw a polygon procedure turtlec(){ cout‫“‏<<‏‬How‫‏‬many‫‏‬sides?” int nsides; cin >> nsides; repeat(nsides){ forward(10); right(360/nsides); } } 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.   Repeat Statement  repeat (x) { ... } : causes the instructions inside { } to be executed x times. More procedures for you  penup(): Causes the pen to be raised. pendown(): Causes the pen to be lowered.   (): Unlike forward which needs one number to decide how much forward to move, penup/down does not need any numbers. Repeat within repeat repeat(4){ repeat(3){ forward(10); penup(); forward(10); pendown(); } right(90); } A necessary Mantra Put following lines in your file #include ; This allows you to use the turtle simulator. Homework  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.

Related docs
CS 7 Introduction to Computer Programming
Views: 6  |  Downloads: 0
CS 0007 Introduction to Computer Programming
Views: 1  |  Downloads: 0
CS 210 - Introduction to Computer Science
Views: 10  |  Downloads: 0
CS 101 Course Summary
Views: 0  |  Downloads: 0
Introduction to Computing (CS 101)
Views: 29  |  Downloads: 2
premium docs
Other docs by moti
Background Check Permission (Comprehensive)
Views: 465  |  Downloads: 30
SALES FOLLOW UP LETTER
Views: 851  |  Downloads: 60
Dirty Joke Doc I Got A Problem
Views: 2760  |  Downloads: 14
MAILING LIST ORGANIZER
Views: 508  |  Downloads: 33
Board Resolution Designating a Purchasing Agent
Views: 242  |  Downloads: 4
DIRECT DEPOSIT AUTHORIZATION
Views: 270  |  Downloads: 3
Board Resolution Authorizing New Borrowing
Views: 179  |  Downloads: 3
Shareholders Resolution Appointing Directors
Views: 250  |  Downloads: 4