The zyLab exercises for this week are visible and available on your zyBooks account.
(If you would like to practice first, do the short training exercises in 1.12 and 1.13).
Open a terminal window on your screen. Inside the terminal window, you will be in a regular linux shell, which basically displays a prompt and waits for you to type a command. The TA may present an overview of useful Linux commands in this lab session (many of the commands were also presented in the class lecture).
To get started, you can follow the recipe below.
Note: the description below is for the setup where you work on all your files in your personal space, and then when you are done you submit the required files by copying them to your dropbox under the course directory. An alternative setup would be to go straight to your dropbox, and do all the work there; that way you don't have to copy files across the network; but with that alternate model, you would not have a copy in your personal space, you would just have the files in the course directory. It's up to you what model you prefer.
For organizational purposes, it is recommended that you first create a directory for this course; then you will basically create a sub-directory for each lab during this semester. And you will do the same under your personal dropbox in the course directory, where you will submit a copy of your files.
So, to get started, from your home directory:
Of course, you can name your directory anything you want.
You now have your own directory for this course in your personal space, which you can use for the whole semester.
Now, for this lab, create a lab1 (or any name of your choosing) under your own course directory:
And now cd into the newly created directory.
Your prompt may indicate what directory you're in, but it's usually a good idea to type pwd every now and then to double check.
Note that if you are in your home directory, you can go straight to that lab1 directory in just one command: cd cse20311/lab1
Text Editor: Most Linux systems come with several editors, such as nano, vi/vim, gedit, emacs, etc., and you are welcome to figure them out and use them on your own. You may use any editor you want. You will soon identify that one text editor that you are most comfortable with. We recommend vim, but some of you may prefer nano which is quite easier to learn at first.
You may incidentally find it more practical to have two terminals, both at the same directory, one for editing a program, one for running commands.
In class you have learned the following Linux commands: pwd, mkdir, cd, ls, mv, cp. That's enough to get started. There is much more to learn about Linux, but you will pick it up week by week with practice.
Let's now start with the programs for lab 1.
Create a C++ program (prog3.cpp) that computes the result of a non-trivial formula of two or more inputs that is useful to you. Choose a formula that you are familiar with, perhaps something from another math or science class. The program should ask the user for each of the relevant input variables, then display the result of the formula.
If your formula needs non-integer values, declare your variables as float (or double) instead of int. You may assume that the user will always input valid data, so no need to check and verify.
This particular lab report should explain the following things:
All submissions will be done electronically, will will actually make life a little easier for you as well as for the graders.
Copy all of your source files (prog1.cpp, prog2.cpp, prog3.cpp) and the lab report (report.txt) into your personal handin directory, in the course directory's dropbox. You will first need to create a lab1 directory under your personal dropbox, which is where your files will be submitted. It is important that the directory be created before you attempt to copy files to it.
(Hint: to save time, after having run the above command, you can then use the up-arrow to bring it back and modify it for the other files, and then run the modified command)
You can verify that your files are handed in by going to that directory, and running the ls command.
Note: in the dropbox, you must name the directory lab1, since this is where your homework files will be submitted; in your personal home directory, you may of course give your directories any names you want; in case you give them the same name, make sure you don't confuse them.
Note that we will soon learn how to create symbolic links, which will make all the above much shorter and quicker!
If you find a mistake after turning in but before the deadline, you can update your submission by simply copying the necessary files again. You are free to turn in assignments multiple times before the deadline expires.
Note: you may of course use any means of your choice to submit the files. However, learning how to do it (and how to do many other tasks) at the command line will become an essential, and soon necessary, skill to have.