CS1100 Introduction to Programming

42
CS1100 – Introduction to Programming

Transcript of CS1100 Introduction to Programming

Page 1: CS1100 Introduction to Programming

CS1100 – Introduction to Programming

Page 2: CS1100 Introduction to Programming

Course Outline

• Introduction to Computing.

• Programming (in C).

• Exercises and examples from various domains.

• Problem solving using computers.

Logistics:

• Instructor: Meghana Nasre.

• Class Hours: 3 times a week.• Wed. 11.00am – 11.50am• Thurs. 9.00am – 9.50am• Fri. 8.00am – 8.50am

• Venue : CRC 101.

Page 3: CS1100 Introduction to Programming

Course Outline

• Introduction to Computing.

• Programming (in C).

• Exercises and examples from various domains.

• Problem solving using computers.

Logistics:

• Instructor: Meghana Nasre.

• Class Hours: 3 times a week.• Wed. 11.00am – 11.50am• Thurs. 9.00am – 9.50am• Fri. 8.00am – 8.50am

• Venue : CRC 101.

Page 4: CS1100 Introduction to Programming

What is CS1100 about?

• Computer and its components.

• Computing.

• Programming Languages.

• Problem Solving and Limitations of a Computer.

Page 5: CS1100 Introduction to Programming

What is a computer?

What is a computer?

• A huge electrical circuit.

• Can accept data fromexternal world, processit, return results to theexternal world.

• What processing can beperformed?

• Determined by theprogram stored on thecomputer.

Page 6: CS1100 Introduction to Programming

What is a computer?

What is a computer?

• A huge electrical circuit.

• Can accept data fromexternal world, processit, return results to theexternal world.

• What processing can beperformed?

• Determined by theprogram stored on thecomputer.

Page 7: CS1100 Introduction to Programming

What is a computer?

What is a computer?

• A huge electrical circuit.

• Can accept data fromexternal world, processit, return results to theexternal world.

• What processing can beperformed?

• Determined by theprogram stored on thecomputer.

Page 8: CS1100 Introduction to Programming

What is a program?

• Program is a precise description of steps that we want toperform on the data.

• Goal of the course: learn to program the computer to performdifferent tasks.

• Programming language: means of communication with acomputer.

• In this course : The C Programming Language• Developed by Dennis Ritchie (1969 – 1973).• Used to “write” the Unix operating system.• One of the most popular programming language.

Page 9: CS1100 Introduction to Programming

What is a program?

• Program is a precise description of steps that we want toperform on the data.

• Goal of the course: learn to program the computer to performdifferent tasks.

• Programming language: means of communication with acomputer.

• In this course : The C Programming Language• Developed by Dennis Ritchie (1969 – 1973).• Used to “write” the Unix operating system.• One of the most popular programming language.

Page 10: CS1100 Introduction to Programming

What is a program?

• Program is a precise description of steps that we want toperform on the data.

• Goal of the course: learn to program the computer to performdifferent tasks.

• Programming language: means of communication with acomputer.

• In this course : The C Programming Language• Developed by Dennis Ritchie (1969 – 1973).• Used to “write” the Unix operating system.• One of the most popular programming language.

Page 11: CS1100 Introduction to Programming

What is a program?

• Program is a precise description of steps that we want toperform on the data.

• Goal of the course: learn to program the computer to performdifferent tasks.

• Programming language: means of communication with acomputer.

• In this course : The C Programming Language• Developed by Dennis Ritchie (1969 – 1973).• Used to “write” the Unix operating system.• One of the most popular programming language.

Page 12: CS1100 Introduction to Programming

Goal for today – have fun!

Observe the following patterns:

********************************

********************

********* ** ** *********

• It is very easy to draw to the patterns on paper.

• How about describing the same to a friend on phone?

Page 13: CS1100 Introduction to Programming

Goal for today – have fun!

Observe the following patterns:

********************************

********************

********* ** ** *********

• It is very easy to draw to the patterns on paper.

• How about describing the same to a friend on phone?

Page 14: CS1100 Introduction to Programming

Describing a pattern

• How do you communicate?

• Use commonly understood commands.

• draw a star.• go to new line.• repeat a set of commands k times.

****************

• repeat 8 times• draw a star.

• go to new line.

• repeat 8 times• draw a star.

Page 15: CS1100 Introduction to Programming

Describing a pattern

• How do you communicate?

• Use commonly understood commands.

• draw a star.• go to new line.• repeat a set of commands k times.

****************

• repeat 8 times• draw a star.

• go to new line.

• repeat 8 times• draw a star.

Page 16: CS1100 Introduction to Programming

Describing a pattern

• How do you communicate?

• Use commonly understood commands.

• draw a star.• go to new line.• repeat a set of commands k times.

****************

• repeat 8 times• draw a star.

• go to new line.

• repeat 8 times• draw a star.

Page 17: CS1100 Introduction to Programming

Can you describe all patterns?

********************************

********************

********* ** ** *********

• draw a star.

• go to new line.

• repeat a set of commands k times.

• move right (without drawing a star).

Page 18: CS1100 Introduction to Programming

Can you describe all patterns?

********************************

********************

********* ** ** *********

• draw a star.

• go to new line.

• repeat a set of commands k times.

• move right (without drawing a star).

Page 19: CS1100 Introduction to Programming

Summarizing..

What have we achieved?

• Describe simple patterns using a set of commands.

• When required, introduce new commands.(and also inform the friend of its meaning).

• It is a program? Yes

• Is it a program in C? No

• To be able to write programs in C, we need to learn thelanguage.

• That is the goal of this course.

Page 20: CS1100 Introduction to Programming

Summarizing..

What have we achieved?

• Describe simple patterns using a set of commands.

• When required, introduce new commands.(and also inform the friend of its meaning).

• It is a program? Yes

• Is it a program in C? No

• To be able to write programs in C, we need to learn thelanguage.

• That is the goal of this course.

Page 21: CS1100 Introduction to Programming

Rest of this week..

• A brief history about computers.

• What is a computer made of?• Do we need to know internals of a computer to be able to

program it?

• How does a computer perform so many diverse tasks (numbercrunching, weather prediction, playing chess, ...)?

• Convert every task into a task on numbers.• How to represent numbers on computers?

Page 22: CS1100 Introduction to Programming

Rest of this week..

• A brief history about computers.

• What is a computer made of?

• Do we need to know internals of a computer to be able toprogram it?

• How does a computer perform so many diverse tasks (numbercrunching, weather prediction, playing chess, ...)?

• Convert every task into a task on numbers.• How to represent numbers on computers?

Page 23: CS1100 Introduction to Programming

Rest of this week..

• A brief history about computers.

• What is a computer made of?• Do we need to know internals of a computer to be able to

program it?

• How does a computer perform so many diverse tasks (numbercrunching, weather prediction, playing chess, ...)?

• Convert every task into a task on numbers.• How to represent numbers on computers?

Page 24: CS1100 Introduction to Programming

Rest of this week..

• A brief history about computers.

• What is a computer made of?• Do we need to know internals of a computer to be able to

program it?

• How does a computer perform so many diverse tasks (numbercrunching, weather prediction, playing chess, ...)?

• Convert every task into a task on numbers.• How to represent numbers on computers?

Page 25: CS1100 Introduction to Programming

Rest of this week..

• A brief history about computers.

• What is a computer made of?• Do we need to know internals of a computer to be able to

program it?

• How does a computer perform so many diverse tasks (numbercrunching, weather prediction, playing chess, ...)?

• Convert every task into a task on numbers.• How to represent numbers on computers?

Page 26: CS1100 Introduction to Programming

Books for the course

• Paul Deitel and Harvey Deitel. C: How to Program.

• V. Rajaraman: Computer Programming in C.

• R. G. Dromey: How to Solve It By Computer?

• Kernighan and Ritchie: The C Programming Language.

Page 27: CS1100 Introduction to Programming

Evaluation for the course

• Two Quizzes 30 marks.

• Programming Assignments 25 marks.

• End of Semester Exam 45 marks.

• Attendance taken in the lab and in lectures.

Page 28: CS1100 Introduction to Programming

Programming Assignments

• Lab Slot : Tuesdays 3:00pm 5:00pm.

• Venue : Departmental Computing Facility (DCF) in CSEDept.

Page 29: CS1100 Introduction to Programming

Policies

• Strictly no cell phone usage in class• Keep your cell phone turned off

(Not even in silent mode)• No SMS, chat etc.

• Cell phones will be confiscated if there are violations

• Returned only after 2 weeks

• Repeat violationsStudents will be sent to the Dean (Acad)

Page 30: CS1100 Introduction to Programming

Acknowledgements

• Slides for the course are based on material prepared by facultyof CSE department IITM.

• Ideas will also be drawn from a book by Prof. AbhiramRanade (IITB) (Introduction to programming using C++).

• All images – courtsey Google Images.

• This applies for all slides throughout the course.

Page 31: CS1100 Introduction to Programming

Outline

• A brief history of computers.

• Components of a computer.

• Representing numbers on a computer.

Page 32: CS1100 Introduction to Programming

From Abacus to Apple

• Counting frame.

• One of the earliest formof calculator.

• Still used by kids to dofast simple arithmetic.

• Followed by mechanical calculators by B. Pascal (1642),G. W. Leibniz (1671).

• Used cogs / interlocking gears.• Performed +,−, ∗, /√.• Leibniz is credited of creating the binary system.

Page 33: CS1100 Introduction to Programming

From Abacus to Apple

• Counting frame.

• One of the earliest formof calculator.

• Still used by kids to dofast simple arithmetic.

• Followed by mechanical calculators by B. Pascal (1642),G. W. Leibniz (1671).

• Used cogs / interlocking gears.• Performed +,−, ∗, /√.• Leibniz is credited of creating the binary system.

Page 34: CS1100 Introduction to Programming

Charles Babbage (1791–1871)

• Regarded as the “Fatherof Computer”.

• Conceived of a machinethat has all the parts of amodern computer, input,a memory, a processor,and an output (1850).

Page 35: CS1100 Introduction to Programming

Difference Engine (1850)

Difference engine built from Babbage’s design (London ScienceMuseum).

Page 36: CS1100 Introduction to Programming

Ada Lovlace (1815–1852)

• “Wrote” the descriptionof the mechanicalcomputer of Babbage.

• Regarded as the firstprogrammer ever.

• The programminglanguage ADA is namedafter her.

Page 37: CS1100 Introduction to Programming

Alan Turing (1912 – 1954)

• Father of TheoreticalComputer Science (TCS)and Artificial Intelligence(AI).

• Turing machine – amodel for a generalpurpose computer.

• Turing test – howintelligent is a machine?

Page 38: CS1100 Introduction to Programming

ENIAC 1946

• Electronic Numerical Integerator And Calculator.

• First electronic computer.

• Massive compared to modern PCs (weight 30 tons).

Page 39: CS1100 Introduction to Programming

1946 – 1976

Transistors

Integrated Circuits

Apple Macintosh

Page 40: CS1100 Introduction to Programming

1946 – 1976

Transistors

Integrated Circuits

Apple Macintosh

Page 41: CS1100 Introduction to Programming

Modern computing devices

Page 42: CS1100 Introduction to Programming

What do we learn from History?

• Untiring efforts by several pioneers (Babbage, Turing, VonNeuman, George Boole, Steve Jobs and many unnamedcomputer scientists) have given us the technology that wehave today.

• Several failed attempts and criticisms for path breaking ideas.

• Most of the advances were made by necessity and driven bypassion and immense hard work.