Top-Rated Free Essay
Preview

Introduction to Programming and Computing Lab1

Powerful Essays
876 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Introduction to Programming and Computing Lab1
Lab 01

Introduction to Programming and Computing

|Objectives |

In this lab you are going to learn:

1. History of computing and computers. 2. Components of a computer system. 3. Hardware components. 4. Software systems. 5. Programming languages 6. DOS basic commands. 7. Use of CodeBlocks

|Overview | |

This section reviews some basic important functions needed for this course under MSDOS (Microsoft Disk Operating System) and learn how to write C++ programs. Creating source codes and compiling them will be the most frequent activity that you will do. You will learn about how to use CodeBlocks to create source codes and compile them and execute the output.

|Lab Exercises |(1 hour 45 minutes) |

DOS Exercise
Try the following practical exercises to gain familiarity with the MS-DOS commands.

A. Display contents of a directory

The following activities will demonstrate how you can view the contents of your folder/directory in DOS. Windows uses a new term called folders whereas the original DOS uses the term Directory. Both terms will be interchangeably use but will have the same meaning in this course. Try the following exercises in the Windows Command Prompt.

a. Try out this command and make a mental note of what you see.

dir/w

b. Similarly try out this command and see if there is any difference to output.

dir/p

B. Creating Directories

In DOS, you are allowed to create directories to store your files. Directories are provided to allow you to group similar files together for easy search and reference.

Creating a directory

To create a directory, issue the following command: mkdir .
For example the command: mkdir TCP1231 will create a directory called TCP1231.

Creating a sub-directory

To create a sub-directory you first have to navigate to the directory that you have created and then issue the same command (mkdir) with a new directory name. For example if you are already in the root (c:\ or d:\) and you wish to navigate to the newly created directory TCP1231, issue the following command:

cd TCP1231

The command cd indicates to DOS that you would like to change directory to TCP1231.

If you are in the directory TCP1231, you should be able to see the following prompt, D:\TCP1231>. At this prompt, issue the following command:

mkdir notes

This will create a subdirectory within the directory TCP1231 that is called notes. Confirm the successful creation of this directory by issuing the dir command. DOS uses a tree structure to main its directory.

Navigating the directory
To return to the top directory, simply issue the command: cd ..
(cd with two full stops).

If you are deep in a subdirectory and wishes to quickly return to the root directory, simple issue the following command: cd \

Copying Files
One of the functions that is allowed in all operating systems is the ability to copy files. Moving files is considered a basic function that is provided by DOS. There are two ways to copy files. One is to specify the absolute path of the source file and the destination of the files to be copied. Another way is to use the relative path method.

Copying a single file

The following command enables files to be copied.
Copy
copy C:\student\abu\lab1\myfirstprogram.cpp D:\Lab1\ myfirstprogram.cpp

Copying multiple files from hard disk to diskette

Instead of specifying the exact filenames you may use wildcards * to copy multiple files. copy C:\student\abu\lab1\*.cpp D:\Lab1\

Renaming files
Files that are stored in your diskette can be rename to anything you desire. But take note that these files might already have associated applications with them so be wise in renaming files.

a. Renaming files by copying

You may rename files by using the copy command by specifying a different destination file name in the copy command.

copy C:\student\abu\lab1\myfirstprogram.cpp D:\Lab1\ myprogram.cpp

b. Using the Rename Command

Another way to rename files is by using the rename command. For example if you wish to rename a file called apple.txt to pear.txt simply type the following command :

rename apple.txt pear.txt

c. Directory names can also be renamed by using the command rename in similar fashion.

Code::Blocks
We will be using Code::Blocks in our lab. You are required to download and install Code::Blocks in your personal machine. You may use other editors (Notepad++, Visual Studio, JGrasp, etc) for your revisions and assignments.

Download site: http://www.codeblocks.org/downloads/26

Files to download: codeblocks-10.05-setup.exe, codeblocks-10.05mingw-setup.exe

The lab machines are already equipped with the files and setup. Now……. Run a simple program, HelloWorld.cpp, in Code::Blocks.

1. Create a folder on your desktop and label it as “Lab01”

2. Go to C:\Program Files\CodeBlocks and double click on the codeblocks.exe to open the Code::Blocks editor.

3. Go to File in the main menu of the Code::Blocks editor and click on the New File or Empty File.

4. Click on the File-Save and name the file as HelloWorld.cpp and save it in the “Lab01” folder.

5. Copy the following into the code into HelloWorld.cpp file.

#include using namespace std; int main() { cout

You May Also Find These Documents Helpful

Related Topics