Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 101: Introduction to computer programming and utilization Abhiram Ranade.

Similar presentations


Presentation on theme: "CS 101: Introduction to computer programming and utilization Abhiram Ranade."— Presentation transcript:

1 CS 101: Introduction to computer programming and utilization Abhiram Ranade

2 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.

3 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!

4 Grading 10 % : Quiz 1 25 % : Midterm 10 % : Quiz 2 40 % : Final Examination 7 % : Lab assignments 8 % : Lab Project

5 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

6 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

7 Lab 10 batches, each with about 70 students. 109Friday 87Thursday 65Wednesday 43Tuesday 21Monday 8:30-10:306:30-8:30

8 Which batch are you in? You will receive an e-mail telling you which batch you are in. Please check your e-mail.

9 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.

10 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.

11 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!

12

13 Program to draw a square procedure turtleMain(){ forward(10); right(90); forward(10); right(90); forward(10); right(90); forward(10); }

14 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.

15 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.

16 How to draw a square 2 procedure turtleMain(){ repeat(4){ forward(10); right(90); }

17 How to draw a polygon procedure turtlec(){ cout << “How many sides?” int nsides; cin >> nsides; repeat(nsides){ forward(10); right(360/nsides); }

18 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.

19 Repeat Statement repeat (x) {... } : causes the instructions inside { } to be executed x times.

20 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.

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

22 A necessary Mantra Put following lines in your file #include ; This allows you to use the turtle simulator.

23 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.


Download ppt "CS 101: Introduction to computer programming and utilization Abhiram Ranade."

Similar presentations


Ads by Google