lecture1
lecture1
Spring 2024
Lecture 1:
- Introduction; Course Administration
- Start coding with simple programs Instructor: Preethi Jyothi
- Based on material developed by Prof. Abhiram Ranade and Prof. Manoj Prabhakaran
Computers
• Computers are machines that can be instructed (via programs or code) to carry out a
wide variety of tasks
fi
Programming language for CS101: C++
• C Programming Language (created in 1970s by Dennis Ritchie)
• Developed to build the Unix operating system
• Consistently among the top four programming languages[1]
"The only way to learn a new programming language is by writing programs in it"
- Dennis Ritchie, Creator of the C programming language, Turing Award (1983)
• In your rst lab, you will set up your system and start coding!
fi
fi
fi
Course Administration and Trivia
CS 101, 2025
Course personnel
• Instructor: Preethi Jyothi (Associate Professor, CSE@IITB, https://www.cse.iitb.ac.in/~pjyothi)
fi
Course logistics
CS101 every week: Two lectures (3 hours), One lab (2 hours)
Lectures: Posted on Moodle right before/after class. Also, additional reading material (at times)
Attendance: Follow institute policy and use SAFE. TAs will mark attendance in labs.
Class Announcements: Made via Moodle or Bodhitree. Please check your emails.
Asynchronous Q&A: Approach your TAs or the course manager (Firuza, [email protected])
fi
Course resources
Website: https://www.cse.iitb.ac.in/~ranade/book.html
Available in physical and online bookstores.
Integrated with use of simplecpp
Course Material: My slides, sample programs, links to additional reading (all on Moodle)
Code of conduct:
Abide by the following honour code.
• Attempt lab exercises on your own. You can consult TAs, classmates, reference
material, but work on the submissions by yourself. Very useful to identify gaps in
understanding.
• If you need help, contact the personnel! (Recall: Extra help sessions.)
• If caught for copying or plagiarism, name of both parties will be handed over to
the Department Disciplinary Action Committee (DDAC)1.
1http://www1.iitb.ac.in/newacadhome/punishments201521July.pdf
Let's Get Coding!
CS 101, 2025
First program: Drawing pictures
if error
if error
Instruct your
Use an editor
Use a C++ OS to
(e.g., vim) or
compiler execute the
an IDE text le binary le
(e.g., g++) code (e.g.,
(e.g.,
via shell
VSCode)
commands)
Write Compile Run
fi
fi
Errors or Bugs
[1] https://en.wikipedia.org/wiki/2024_CrowdStrike-related_IT_outages
fi
fi
Redundancy in code?
#include <simplecpp>
main_program {
turtleSim();
forward(100); right(90);
forward(100); right(90);
forward(100); right(90);
forward(100);
getClick();
}
Use the repeat statement
repeat(n) {
⋮
body
⋮
} body consists of one or more statements
• More about indentation later, as you learn more about conditional blocks, loops, functions, etc.
More simplecpp commands
• penUp(), penDown(): Pen is raised or lowered, respectively. To get the turtle to draw as it
moves, the pen should be lowered.
• hide(): Pen visual (a triangle) is hidden