Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Objectives:
The objectives of this lab exercise are as follows.
1. Practicing commands in Linux
2. Running a C++ program
Note : In this lab you are required to follow the lab sheet given below. You can get help
from your instructors to complete portions, which you find difficulties. You should try to
complete all the exercises given in the Lab Sheet.
Student
IPE CF TC
Week 1
-1-
4. Do the following tasks
1. Copy file1.txt from “IPE” directory to “CF” directory and rename it as
“test1.txt”.
2. Copy file2.txt from “IPE” directory to “Week 1” directory in “TC” directory
and rename it as “test2.txt”.
3. Copy file3.txt from “CF” directory to “IPE” Directory.
4. Go to the DIT_10_C1_000 Directory and copy the “file1.txt” to the “TC”
Directory.
5. Remove the “IPE” Directory.
1. To get into a vi editor type vi lab1ex2.cpp and enter. (Note: lab1ex2.cpp is going to
be the name of your program. You may also use a name of your choice. But do not
change the extension, .cpp)
2. Type the following Program, which converts the temperature in Fahrenheit to Celsius.
#include<iostream>
using namespace std;
int main()
{
double Celsius, Fahrenheit;
Fahrenheit = 95.0;
Celsius = (Fahrenheit - 32) * 5.0/9.0;
cout<<Fahrenheit<<”degrees Fahrenheit is”<<Celsius;
cout << ”degrees Celsius.\n”;
return 0;
} //main
Note: If you are not familiar with the vi editor type vimtutor in a different terminal to
open the tutorial. This tutorial explains enough commands for you to easily work with the
vi editor.
-2-
Once the program has been created using the vi editor, you can exit from the vi
editor and get back to the command prompt by pressing the Esc key and “ : “ key
consecutively. Then type wq and press enter.
-3-