You are on page 1of 21

CS 101

Computer Programming
and Utilization
Bharat
with
several CS101 TAs and CSE staff

Course webpage: https://www.cse.iitb.ac.in/~cs101/

Lab1: Getting Started

Clip art and quote credits: Various sources found through Google
Image Search
Goals of this lab

• The goal of this lab is to become familiar with the


following:
– Ubuntu navigation
– Basic usage of bash/terminal
– Web browser, text editor
– Bodhitree interface
– Files, directories, web pages
– Codeblocks, s++

07/25/19 Spring 2019 CS101@CSE IIT Bombay 2


Login into Lab Machines
• You will see a screen similar to this
• Press enter key on your keyboard
• Enter the following password
labuser
• Click Unlock.

• You will see ubuntu desktop


screen. Ubuntu is an operating
system, an alternative to
Windows and Mac
07/25/19 Spring 2019 CS101@CSE IIT Bombay 3
Ubuntu Navigation and Directories
• You will see some icons on the left of your desktop
• Click on ‘Files’ icon.
• A window will open up.
• This shows ‘Home’ directory
• You can see some folders
• Currently, ‘Home’ is selected

• Click ‘Downloads’
• All files that you download
from the internet will go
in this folder
Show Applications Icon
07/25/19 Spring 2019 CS101@CSE IIT Bombay 4
Files
• Way of storing information in various formats
• Files are stored in a directory/folders
• Different file formats have different extensions
• Example
○ Text: .txt, .c, .cpp, .py
○ Word: .doc, .docx
○ Document: .pdf
○ Excel: .xls, .xlsx
○ Libre Writer: .odt
○ Libre Impress: .odp
○ Images: .png, .jpg, .bmp
○ Video: .mp4, .ogg
○ Audio: .wav, .mp3
07/25/19 Spring 2019 CS101@CSE IIT Bombay 5
Text editor
• A software in which you are able to write, save, cut, copy,
paste, etc. Examples (gedit, vi, etc.)
• Open gedit by clicking ‘Show Applications icon’,
type ‘gedit’, select. You will see a new file opened up.
Write something into the file. Click ‘Save’

• Write your filename and click ‘Save’ (green button)

07/25/19 Spring 2019 CS101@CSE IIT Bombay 6


Text editor
● The saved file will look like below

● Click on the 3 horizontal lines, and explore the options

07/25/19 Spring 2019 CS101@CSE IIT Bombay 7


Text editor
● Locate the file in the directory
● Click on Files folder
● You will be in the home directory.
● Select the text file you just created, myfirstfile.txt
● Press Ctrl + c
● Press Ctrl + v
● A new file will be created
● Double click to open the new file
● You will see the same content that you wrote
● Change some text and save it. (Ctrl + s)
● Now open the original file (myfirstfile.txt)
● You will see that the original file is not changed

07/25/19 Spring 2019 CS101@CSE IIT Bombay 8


Web browser
• An application using which we can view the information
given on the web (news, sports, songs, movies, etc.)
• Google Chrome, Mozilla Firefox, Safari, etc.
• Click ‘Show Applications’ icon
– located in the bottom left
• Type Google chrome and click on the icon
• The browser will open up URL bar

• It will look similar to this

07/25/19 Spring 2019 CS101@CSE IIT Bombay 9


Basic Shell commands (Terminal)
• Press Ctrl + Alt + t. A terminal opens up.
• Write pwd and press enter (print working directory)
○ It shows your current folder path
• Write ls and press enter
○ It lists the files and folders in your current folder
• Write mkdir test and press enter (make directory)
○ Creates a folder called test
• Write cd test and press enter(change directory)
○ Changes your directory to test
• Write cd .. and press enter (go one level up)
○ Takes you one level up
• Write cp myfirstfile.txt second.txt
○ Creates second.txt with the contents of myfirstfile.txt
07/25/19 Spring 2019 CS101@CSE IIT Bombay 10
Code::Blocks
• An IDE for compiling and executing C/C++ programs
• Click and type codeblocks. Click
• You will first see Simple::Blocks screen

• A new window will open.


• Select GCC with simpleCPP
• Click Ok
• This screen appears only once
• You may or may not get
this screen
07/25/19 Spring 2019 CS101@CSE IIT Bombay 11
Code::Blocks (Basic Program)
• Save the file
• as hello.cpp
• in your home directory
cout << “hello”;
• Write the following
after main_program{
○ cout << “hello”;
• Click Build and run
• A new window opens up

07/25/19 Spring 2019 CS101@CSE IIT Bombay 12


Code::Blocks (Graphics Program 1)

• Create a new file called “square.cpp” in your home


directory and write the following program in it.
• Play around with the
code as you want and
see what happens.

07/25/19 Spring 2019 CS101@CSE IIT Bombay 13


Code::Blocks (Graphics Program 2)

• Create a new file called “polygon.cpp” in your home


directory and write the following program.
• Instructions for
running the code are
in the next slide

07/25/19 Spring 2019 CS101@CSE IIT Bombay 14


s++ (Simplecpp)
• Press Ctrl + Alt + t. A terminal opens up.
• Write ls and press enter
• You will see the file ‘polygon.cpp’, and possibly some
other existing files
• Write: s++ polygon.cpp
• Press enter. This will compile the program
• Write: ./a.out
• Press enter. This will execute the program.
• Write 5 on the terminal
• Press enter
• The turtle simulator will open up showing a pentagon
• Try running “a.out” again with different values (6,7, etc).
07/25/19 Spring 2019 CS101@CSE IIT Bombay 15
Preparing for upload
• Click on Files folder
• Create a new folder (Right click > New Folder)
• Write your roll number as the folder name
• Copy only hello.cpp, square.cpp, and polygon.cpp in this
folder
• Do NOT copy any other file
• Right click on the folder > Click compress > Create
• A new file will be created which will be similar to:
○ Rollnumber.zip

07/25/19 Spring 2019 CS101@CSE IIT Bombay 16


Bodhitree (http://cs101.bodhi.cse.iitb.ac.in/)
• All lab related activity will happen on this interface,
such as submissions, evaluations, etc.
• Accounts have already been created for everyone, with
your Roll Number as the user ID as well as the
password.
• After the first login, please change the password to
something you can remember.
• You have been enrolled in “CS101 Winter 2020” course
automatically. This is the page for the course.
• Detailed steps are on the next slides

07/25/19 Spring 2019 CS101@CSE IIT Bombay 17


Webmail
• Open your webmail (webmail.iitb.ac.in)

• You would have


received the
email similar to
this one.
• Click on the link
given in the
email

07/25/19 Autumn 2019 CS101@CSE IIT Bombay 18


Bodhitree
• Create a password for your
account. Click ‘Submit’
• You will see CS101 Winter
2020 listed. Click on the link
and explore

07/25/19 Autumn 2019 CS101@CSE IIT Bombay 19


Assignments
• As a part of this lab, you need to submit the .zip file (containing the
3 programs) which you just created
Login into http://cs101.bodhi.cse.iitb.ac.in/
■ Select CS101 Winter 2020 → Programming Assignments
■ Click Lab 1 → Choose file → Double click the .zip file you
just created (YourRollNo.zip) → Upload
■ Click Run Practice Test case

07/25/19 Autumn 2019 CS101@CSE IIT Bombay 20


Homework / Extra work

• Try out simplecpp programs done in the class

07/25/19 Spring 2019 CS101@CSE IIT Bombay 21

You might also like