Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

Computer Programming Lab Manual - 1-9

The document is a lab manual for a computer programming course, detailing practical exercises for software applications including Windows OS installation, Microsoft Word, PowerPoint, Excel, MS-DOS, and C++. Each lab includes tools, background information, and procedures for completing tasks. The manual aims to equip students with hands-on experience in various computer applications and programming fundamentals.

Uploaded by

zaminstocks1
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Computer Programming Lab Manual - 1-9

The document is a lab manual for a computer programming course, detailing practical exercises for software applications including Windows OS installation, Microsoft Word, PowerPoint, Excel, MS-DOS, and C++. Each lab includes tools, background information, and procedures for completing tasks. The manual aims to equip students with hands-on experience in various computer applications and programming fundamentals.

Uploaded by

zaminstocks1
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 114

Computer Programming

List of Practicals

Lab 01: Installing Windows Operating System and Disk Partitioning

Lab 02: Creating and Editing Documents with Microsoft Word

Lab 03: Creating Documents with Advance Formatting Operations of Microsoft Word

Lab 04: Creating and Editing Multimedia Presentations with Microsoft PowerPoint

Lab 05: Creating Presentations with Advance Operations of Microsoft PowerPoint

Lab 06: Creating and Editing Spreadsheets With Microsoft Excel

Lab 07: Creating Spreadsheets with Advance Operations of Microsoft Excel

Lab-08: Working with Microsoft Disk Operating System (MS-DOS)

Lab-09: Getting familiar with Fundamentals of Programming Using C++

Introduction to Computer & Progra


LAB MANUAL

By: Engr. Mahaveer Rathi


Computer Programming

Table of Contents
Lab 01: Installing Windows Operating System and Disk Partitioning.... .1
1.1 Tools................................................................................................................ 1
1.2 Background...................................................................................................... 1
1.2.1 Operating System..................................................................................... 1
1.2.2 Bootable Media......................................................................................... 1
1.2.3 Rufus......................................................................................................... 2
1.3 Procedure........................................................................................................ 2
Creating bootable USB using Rufus.......................................................................2
Installing Windows 10 from bootable USB.............................................................3
EXERCISE............................................................................................................... 8
Lab 02: Creating and Editing Documents with Microsoft Word...............9
2.1 Tools................................................................................................................ 9
2.2 Background...................................................................................................... 9
2.2.2 Microsoft Word 2013 Interface...............................................................9
2.2.2.1 Home Tabs......................................................................................... 11
2.2.2.2 Insert Tabs......................................................................................... 11
2.3 Formatting Text............................................................................................. 11
2.4 Procedure...................................................................................................... 11
2.4.1 Creating a blank document..................................................................11
2.4.2 Changing the font of text.....................................................................12
2.4.3 Changing the font size.........................................................................12
2.4.4 Changing the font color.......................................................................12
2.4.5 Using the Bold, Italic, and Underline commands..................................12
2.4.6 Changing the text case........................................................................13
2.4.7 Changing the text alignment...............................................................13
2.4.8 Changing line spacing..........................................................................13
2.4.9 Changing paragraph spacing...............................................................13
2.4.10 Changing paragraph indent...................................................................13
2.4.11 Creating bulleted list.............................................................................14
2.4.12 Creating numbered list..........................................................................14
2.4.13 Creating multilevel list...........................................................................14
2.4.14 Creating header and footer...................................................................15
2.4.15 Adding page number to a document.....................................................15
2.4.16 Inserting a picture from a file................................................................15
2.4.17 Wrapping text around an image............................................................15
Computer Programming

EXERCISE............................................................................................................. 16
Lab 03: Creating Documents with Advance Formatting Operations of
Microsoft Word.................................................................................19
3.1 Tools.............................................................................................................. 19
3.2 Background.................................................................................................... 19
3.2.1 Tables in MS Word............................................................................... 19
3.2.2 Smart Art............................................................................................. 19
3.2.3 Symbols............................................................................................... 19
3.2.4 Equations............................................................................................. 19
3.3 Procedure..................................................................................................... 20
3.3.1 Creating a blank table.............................................................................20
3.3.2 Modifying tables....................................................................................... 20
3.3.2.1 To add a row or column.....................................................................20
3.3.2.2 To delete a row or column.................................................................20
3.3.2.3 To apply a table style........................................................................20
3.3.2.4 Merge and Split Cells.........................................................................21
3.3.2.5 Splitting a table................................................................................. 21
3.3.3 To insert a SmartArt graphic....................................................................21
3.3.3.1 To add text to a SmartArt graphic.................................................22
3.3.3.2 To change the SmartArt layout......................................................22
3.3.4 To insert a symbol................................................................................ 23
3.3.5 To insert an equation...........................................................................23
EXERCISE............................................................................................................. 24
Lab 04: Creating and Editing Multimedia Presentations with Microsoft
PowerPoint......................................................................................27
4.1 Tools.............................................................................................................. 27
4.2 Background.................................................................................................... 27
4.2.1 MS PowerPoint..................................................................................... 27
4.2.2 The PowerPoint 2013 Interface............................................................27
4.2.3 The Ribbon........................................................................................... 28
4.2.3.1 Home Tab.......................................................................................... 28
4.2.3.2 Insert Tab.......................................................................................... 28
4.2.3.3 Design Tab......................................................................................... 28
4.2.3.4 Transitions Tab.................................................................................. 28
4.2.3.5 Animations Tab.................................................................................. 29
4.2.4 Backstage view........................................................................................ 29
4.2.5. Slide Basics............................................................................................. 30
4.2.6 Themes................................................................................................... 30
Computer Programming

4.2.7 Transitions............................................................................................... 30
4.3 Procedure...................................................................................................... 31
4.3.1 Creating a new presentation................................................................31
4.3.2 Inserting new slide............................................................................... 32
4.3.2.1 Managing slides................................................................................. 32
4.3.2.2 Customizing slides............................................................................. 32
4.3.2.3 Applying Transitions......................................................................32
EXERCISE............................................................................................................. 33
Lab 05: Creating Presentations with Advance Operations of Microsoft
PowerPoint......................................................................................36
5.1 Tools.............................................................................................................. 36
5.2 Background.................................................................................................... 36
5.2.1 Word Art............................................................................................... 36
5.2.2 Chart.................................................................................................... 36
5.2.3 Animating Text and Objects.................................................................36
5.3 Procedure...................................................................................................... 37
5.3.1 Inserting a picture................................................................................ 37
5.3.2 Applying WordArt style to a text..........................................................37
5.3.3 Inserting a shape................................................................................. 38
5.3.4 Inserting an audio................................................................................ 38
5.3.5 Inserting an video................................................................................ 38
5.3.6 Inserting a blank table.........................................................................38
5.3.7 Modifying tables................................................................................... 38
5.3.7.1 To add a row or column.................................................................38
5.3.7.2 To delete a row or column.............................................................39
5.3.8 To insert a chart................................................................................... 39
5.3.8.1 To apply an animation to an object...............................................40
5.3.8.2 To add multiple animations to an object........................................40
5.3.8.3 To open the Animation Pane..........................................................41
5.3.8.4 To change an effect's start option.................................................41
EXERCISE............................................................................................................. 42
Lab 06: Creating and Editing Spreadsheets with Microsoft Excel.........46
6.1 Tools.............................................................................................................. 46
6.2 Background.................................................................................................... 46
6.2.1 MS Excel............................................................................................... 46
6.2.2 The Excel 2013 Interface.....................................................................46
6.2.3 The Ribbon........................................................................................... 47
Computer Programming

6.2.3.1 Home Tab.......................................................................................... 47


6.2.3.2 Insert Tab.......................................................................................... 47
6.2.3.3 Formulas Tab..................................................................................... 48
6.2.3.4 Data Tab............................................................................................ 48
6.2.3.5 Worksheet Views..............................................................................48
6.2.4 Cell Basics............................................................................................ 49
6.2.5 Cell....................................................................................................... 49
6.2.6 Fill handle............................................................................................ 50
6.2.7 Flash fill................................................................................................ 50
6.3 Procedure...................................................................................................... 50
6.3.1 To create a new blank workbook.........................................................50
6.3.2 To manage worksheets........................................................................50
6.3.3 To select a cell..................................................................................... 51
6.3.4 To select a range................................................................................. 51
6.3.5 To delete cells...................................................................................... 51
6.3.6 To use fill handle.................................................................................. 51
6.3.7 To use flash fill..................................................................................... 51
6.3.8 To merge cells using the Merge & Center command...........................52
EXERCISE............................................................................................................. 53
Lab 07: Creating Spreadsheets with Advance Operations of Microsoft
Excel...............................................................................................55
7.1 Tools.............................................................................................................. 55
7.2 Background.................................................................................................... 55
7.2.1 Formatting text and numbers..............................................................55
7.2.2 Simple Formulas.................................................................................. 56
7.2.2.1 Mathematical Formulas.................................................................56
7.2.2.2 Cell references............................................................................... 56
7.2.3 Complex Formulas............................................................................... 56
7.2.4 Order of operations..............................................................................57
7.3 Functions.................................................................................................... 57
7.3.1 Working with arguments......................................................................57
7.3.2 The Function Library............................................................................58
7.4 Sorting Data............................................................................................... 58
7.5 Filtering Data............................................................................................. 59
7.6 Charts......................................................................................................... 59
7.7 Procedure...................................................................................................... 59
7.7.1 To apply number formatting................................................................59
Computer Programming

7.7.2 To create a formula.............................................................................. 59


7.7.3 To create a formula using the point-and-click method.........................60
7.7.4 To create a complex formula...............................................................61
7.7.5 To create a basic function....................................................................61
7.7.6 To create a function using the AutoSum command.............................62
7.7.7 To insert a function from the Function Library.....................................62
7.7.8 To sort a sheet..................................................................................... 63
7.7.9 To sort a range..................................................................................... 64
7.7.10 To filter data.......................................................................................... 64
7.7.11 To insert a chart.................................................................................... 65
EXERCISE............................................................................................................. 67
Lab-08: Working with Microsoft Disk Operating System (MS-DOS).......71
8.1 Tools.............................................................................................................. 71
8.1 Background.................................................................................................... 71
8.2.1 MS-DOS................................................................................................ 71
8.2.2 Windows Command Line......................................................................71
8.2.3 MS-DOS Commands.............................................................................71
8.2.8.1 Internal Commands..........................................................................72
8.2.8.2 External Commands..........................................................................72
8.2.4 Common MS DOS Commands..............................................................72
8.2.5 Wildcard characters............................................................................. 73
8.3 Procedure...................................................................................................... 74
8.3.1 How to open command prompt...............................................................74
8.3.2 How to enter command...........................................................................75
EXERCISE............................................................................................................. 76
Exercise 8.2: Write MS DOS commands for the followings...............................76
Lab-09: Getting Familiar with Fundamentals of Programming using C++
.......................................................................................................79
Tools.................................................................................................................... 79
9.1 Introduction................................................................................................ 79
9.1.1 C++ Programming Language..................................................................79
9.1.2 History of C++......................................................................................... 79
9.1.3 Code::Blocks............................................................................................ 80
9.1.4 Basic C++ Program................................................................................. 81
9.1.5 Functions................................................................................................. 82
9.1.6 Statements.............................................................................................. 83
9.1.7 Preprocessor Directives and the Header Files.........................................83
9.1.8 Standard Input and Output Streams........................................................84
Computer Programming

9.1.9 Outputting with cout................................................................................ 84


9.1.10 Inputting with cin................................................................................... 86
9.1.11 Comments............................................................................................. 87
9.1.12 Variables................................................................................................ 88
9.1.12.1 Declaring and Defining a Variable...................................................88
9.1.13 Data Types............................................................................................ 90
9.1.13.1 Integer data type.............................................................................90
9.1.13.2 Floating point data type..................................................................91
9.1.13.3 Character Data Type.......................................................................92
9.1.13.4 Unsigned data types........................................................................93
9.1.14 The const Qualifier................................................................................. 94
9.1.15 Assignment Statements.........................................................................95
9.1.16 The endl Manipulator.............................................................................95
9.1.17 Arithmetic Assignment Operators..........................................................96
9.1.18 Relational Operators.............................................................................. 97
9.1.19 Logical Operators................................................................................... 98
9.1.20 Increment Operators.............................................................................. 99
9.2 Procedure................................................................................................. 100
9.2.1 Problem example................................................................................... 100
9.2.2 Source Code in Code::Blocks.................................................................100
EXERCISE........................................................................................................... 103
Computer Programming

LAB 01: INSTALLING WINDOWS OPERATING SYSTEM AND


DISK PARTITIONING

Upon successful completion of this lab the students will be able to:
• Create bootable media for Windows installation.
• Install Windows 10 via bootable USB stick.
• Create partitions using windows setup and disk management.
1. TOOLS
1
• Bootable Windows 10 ISO file.
• Removable media (USB 4GB or more).
• Rufus software.
1. BACKGROUND
2
1.2.1 Operating System
Operating system is a system software that enables the computer hardware to
communicate and operate with the computer software. It control’s computer
hardware and interacts with the user and application software. Number of
operating systems are available, few of them are listed below:

• MS-DOS (By Microsoft)  UNIX


• PC-DOS (By IBM)  Ubuntu Linux
• Windows 95  KUbuntu Linux
• Windows 98  RedHat Linux
• Windows 2000  Fedora Linux
• Windows ME (Millennium Edition)  Mac iOS
• Windows XP  iPhone OS
• Windows Vista  Android
• Windows 7  Symbian
• Windows 8  Blackberry OS
• Windows 8.1  Windows Phone
• Windows 10  Ubuntu for Mobile

1.2.2 Bootable Media


Bootable media is any removable disk from which the computer can load and
boot (start) from. It contains a bootable program such as operating system. The
media that can be created as bootable are: Floppy, USB, CD, DVD etc.

Lab Manual Page 1 of 104


Computer Programming

1.2.3 Rufus
Rufus is the utility used to format and create bootable USB drives, pen drives,
flash cards etc. Rufus supports both, Master Boot Record (MBR) or GUID Partition
Table (GPT) partition systems.

Figure 1.1: Rufus Interface


1. PROCEDURE
3
Creating bootable USB using Rufus
Step 01: Download Windows 10 ISO image file.
Step 02: Download Rufus from https://rufus.akeo.ie/ and execute.
Step 03: Use the following configuration:

• Device = USB drive


• Partition scheme = MBR for BIOS or UEFI
• File system = NTFS
• Cluster size = 4096 Bytes (Default)
• New volume label = Win10 (you can provide any name)
Step 04: Select ISO Image from drop down list beside “Create a bootable disk
using”.
Step 05: Click the icon beside the drop down list and select Windows10.iso file.
Step 06: Click start to create bootable USB.

Lab Manual Page 2 of 104


Computer Programming

Installing Windows 10 from bootable USB


Step 01: Plug in the bootable USB in to system unit.
Step 02: Restart the computer.
Step 03: In some computers you need to change BIOS boot sequence, to do this:

• Access BIOS setup by pressing setup key continuously at


restart  Set USB as first bootable device in boot sequence.
• Save changes and exit the setup.

In other computers you just need to access boot order and select the bootable
USB.
Note: Setup key on different computer vary, some of the possible keys are: Esc,
Del, F2, F10)

Step 04: Computer now loads windows files from USB.


Step 05: Click Install Now to start.

Figure 1.2: Setting USB as first bootable device in BIOS

Lab Manual Page 3 of 104


Computer Programming

Figure 1.3: Selecting boot from USB-HDD

Figure 1.4: Step 05 – Click to install windows


Step 06: Enter Windows 10 product key and press Next (if available).
Step 07: Check “I accept the license terms to agree” and press Next.
Step 08: Click “Custom: Install Windows only (Advanced)”.

Lab Manual Page 4 of 104


Computer Programming

Step 09: Select and remove all partitions from the Disk.

Figure 1.5: Step 08 – Click Custom Install for fresh installation

10: Select unallocated space and click New, specify the size in MBs for new
partition.

11: Similarly create other partitions.

Figure 1.6: Step 09, 10 & 11 – Deleting and creating partitions


Step 12: Select the partition in which you want to install windows and click Next.
Step 13: The setup will now be copying files and installing the windows (this may
take several minutes depending on your system configuration).

Lab Manual Page 5 of 104


Computer Programming

Figure 1.7: Step 09, 10 & 11 – Copying files and installing windows
14: After the installation is completed, the computer will reboot.

15: Remove the USB from the computer.


Step 16: The setup will now be getting the device ready to use.

Figure 1.8: Step 16 – Getting device ready


Step 17: Click the “Use Express Setting” to use default settings.
Step 18: Skip the Microsoft account login.
Step 19: Create your user account by providing the username and password.

Lab Manual Page 6 of 104


Computer Programming

Figure 1.9: Step 19 – Creating user account


20: Wait until the setup configures the setting and installs the default Apps.

21: The setup has successfully installed windows 10 and the desktop
appears.

Figure 1.10: Step 21– Windows 10 desktop

Lab Manual Page 7 of 104


Computer Programming

EXERCISE
1.1: Create a bootable Windows 10 USB. Note: use any tool
other than Rufus.

a. Describe the entire procedure step by step.


b. With every step, capture and place in the
screenshots.

1.2: Create a bootable Windows 10 USB without using any tool.

a. Describe the entire procedure step by step.


b. With every step, capture and place in the
screenshots.

1.3: Download windows 10 ISO image and install it through


bootable USB:

a. Describe the entire procedure step by step.


b. With every step, capture and place in the screenshots.

Lab Manual Page 8 of 104


Computer Programming

LAB 02: CREATING AND EDITING DOCUMENTS WITH


MICROSOFT WORD

Upon successful completion of this lab the students will be able to:
• Get familiar with MS Word user interface.
• Create and edit documents in MS Word.
• Understand text formatting commands in MS Word.
2. TOOLS
1
• PC with MS Word (Version: 2016, 2013, 2010 or 2007)
2. BACKGROUND
2
2.2.1 Microsoft Word
When you use a computer program to create, edit, and format text documents,
you are performing a task known as word processing. Part of the Microsoft Office
suite of programs, Microsoft Word, is one of the most sophisticated word-
processing programs available.
By using Word, it is easy to efficiently create a wide range of business and
personal documents, from the simplest letter to the most complex report.

2.2.2 Microsoft Word 2013 Interface


When you open Word 2013 for the first time, the Word Start Screen will appear.
From here, you'll be able to create a new document, choose a template, or
access your recently edited documents.
From the Word Start Screen, locate and select Blank document to access the

Word interface.
Figure 2.1: MS Word Start Screen

Lab Manual Page 9 of 104


Computer Programming

Figure 2.2: MS Word Interface


Quick Access Toolbar: Located just above the Ribbon, the Quick Access toolbar
lets you access common commands no matter which tab is selected.
The Ruler: Located at the top and to the left of your document. It makes it easier
to adjust your document with precision.
Document Views: Change how your document is displayed. You can choose to
view your document in Read Mode, Print Layout, or Web Layout.
The Ribbon: Contains all the commands you will need to perform common tasks
in Word. It has multiple tabs, each with several groups of commands.
Command Group: Each group contains a series of different commands. Simply
click any command to apply it. Some groups also have an arrow in the bottom-
right corner, which you can click to see even more commands.
Status Bar: Shows the status of document i.e. number of pages, current page
number, word count, spelling and grammatical errors. It also presents the
documents view controls and zoom controller.
2.2.2.1 Home Tabs

The Home tab gives you access to some of the commonly used commands.

Lab Manual Page 10 of 104


Computer Programming

Figure2 3: Home Tab


.
2.2.2.2 Insert Tabs

The Insert tab allows you to insert pictures, charts, tables, shapes, cover pages,
and more to your document.

Figure 4: Insert Tab


2.
2.3 FORMATTING TEXT
Formatted text can draw the reader's attention to specific parts of a document
and emphasize important information. In Word, you have many options for
adjusting the font of your text, including size, color, and inserting special
symbols. You can also adjust the alignment of the text
to change how it is displayed on the page.
2. PROCEDURE
4
2.4.1 Creating a blank document
Step 01: Select the File tab, backstage view will
appear.
Step 02: Select New, then click Blank document.
Step 03: A new blank document will appear.
2.4.2 Changing the font of text
Step 01: Select the text you wish to modify.
Step 02: On the Home tab, click the drop-down arrow next to the Font box. A
menu of font styles will appear.
Step 03: Move the mouse over the various font styles. A live preview of the font
will appear in the document. Select the font style you wish to use.

2.4.3 Changing the font size


Step 01 Select the text you wish to modify.

Lab Manual Page 11 of 104


Computer Programming

Step 02: Select the desired font size formatting option:


Font size drop-down arrow: On the Home tab, click the Font size drop-down
arrow. A menu of font sizes will appear. When you move the mouse over the
various font sizes, a live preview of the font size will appear in the document.

Font size box: When the font size you need is not available in the Font size drop-
down arrow, you can click the Font size box and type the desired font size. Then
press Enter.

2.4.4 Changing the font color


Step 01: Select the text you wish to modify.
Step 02: On Home tab, click the Font Color drop-down arrow. The Font Color
menu appears.
Step 03: Select the font color you wish to use.

2.4.5 Using the Bold, Italic, and Underline commands


Step 01: Select the text you wish to modify.
Step 02: On Home tab, click the Bold (B), Italic (I), or Underline (U) command in
the Font group.

2.4.6 Changing the text case


Step 01: Select the text you wish to modify.
Step 02: On Home tab, click, Change Case in the Font
group.
Step 03: A drop-down menu will appear. Select the desired
case option from the menu.

2.4.7 Changing the text alignment


Step 01: Select the text you wish to modify.
Step 02: On Home tab, select one of the four alignment options from the
Paragraph group.

Lab Manual Page 12 of 104


Computer Programming

2.4.8 Changing line spacing


Step 01 Select the text you wish to modify.
Step 02: On Home tab, click the Line and Paragraph Spacing command. A drop-
down menu will appear.
Step 03: Move the mouse over the various options. A live preview of the line
spacing will appear in the document. Select the line spacing you wish to use.

2.4.9 Changing paragraph spacing


Step 01: Select the paragraph or paragraphs you wish to format.
Step 02: On Home tab, click the Line and Paragraph Spacing command. Hover
the mouse over Add Space Before Paragraph or Remove Space After Paragraph
from the drop-down menu.
Step 03: Select the paragraph spacing you wish to use.

2.4.10 Changing paragraph indent


Step 01: Select the text you wish to indent.
Step 02: On the Home tab, click the desired Indent command:
Increase Indent: Increases the indent by increments of 1/2 inch.
Decrease Indent: Decreases the indent by increments of 1/2 inch.
2.4.11 Creating bulleted list
Step 01: Select the text you wish to format as
a list.
Step 02: On the Home tab, click the drop-down
arrow next to the Bullets command. A menu of
bullet styles will appear.
Step 03: Move the mouse over the various
bullet styles. A live preview of the bullet style
will appear in the document.
Step 04: Select the bullet style you wish to
use.

2.4.12 Creating numbered list


Step 01 Select the text you wish to format as a list.

Lab Manual Page 13 of 104


Computer Programming

Step 02: On the Home tab, click the drop-down arrow next to the Numbering
command. A menu of numbering styles will appear.
Step 03: Move the mouse over the various numbering styles. A live preview of
the numbering style will appear in the document.
Step 04: Select the numbering style you wish to use.

2.4.13 Creating multilevel list


Step 01: Create a bulleted or numbered list.
Step 02: Place the insertion point at the beginning of the line you wish to move
to right.
Step 03: Press the Tab key to increase the indent level of the line. The line will
move to the right.
Step 04: To increase the indent by more than one level, place the insertion point
at the beginning of the line and press the Tab key until the desired level is
reached.
Step 05: To decrease the indent level, place the insertion point at the beginning
of the line, then hold the Shift key and press the Tab key.

2.4.14 Creating header and footer


Step 01: Double-click anywhere on the top or bottom margin of your document.
Step 02: The header or footer will open, and a Design tab will appear on the right
side of the Ribbon. The insertion point will appear in the header or footer.
Step 03: Type the desired information into the header or footer.
Step 04: When you're finished, click Close Header and Footer. Alternatively, you
can press the Esc key.

2.4.15 Adding page number to a document


Step 01: Double-click anywhere on the header or footer to unlock it.
Step 02: Click the Page Number command from design tab. In the menu that
appears, hover the mouse over Current Position and select the desired page
numbering style.
2.4.16 Inserting a picture from a file
Step 01 Place the insertion point where you want the image to appear.
Step 02: Select the Insert tab on the Ribbon, then click the Pictures command.
Step 03: The Insert Picture dialog box will appear. Select the desired image file,
then click Insert.

Lab Manual Page 14 of 104


Computer Programming

Step 04: To resize an image, click and drag one of the corner sizing handles .
The image will change size while keeping the same proportions. If you want to
stretch it horizontally or vertically, you can use the side sizing handles .

2.4.17 Wrapping text around an image


Step 01: Select the image you want to wrap text around. The Format tab will
appear on the right side of the Ribbon.
Step 02: On the Format tab, click the Wrap Text command in the Arrange group.
A drop-down menu will appear.
Step 03: Hover the mouse over the various text wrapping options. A live preview
of the text wrapping will appear in the document. When you've found the text
wrapping option you want to use, click on it. Alternatively, you can select More
Layout Options... to fine tune the layout.
Step 04: The text will wrap around the image. You can now move the image if
desired. Just click, hold, and drag it to the desired location. As you move it,
alignment guides will appear to help you align the image on the page.
Step 05: Alternatively, you can access text wrapping options by selecting the
image and clicking the Layout Options button that appears.

Lab Manual Page 15 of 104


Computer Programming

EXERCISE
Exercise 2.1: Create and format the following MS WORD document page:

Lab Manual Page 16 of 104


Computer Programming

Exercise 2.2: Create and format the following MS WORD document page:

Exercise 2.3: Create and format the following MS WORD document page:

Lab Manual Page 17 of 104


Computer Programming

Exercise 2.4: Create and format the following MS WORD document page:
Classification of Computers
o On the basis of Purpose
o On the basis of Size
o On the basis of Working Mechanism
Classification of Computers (Purpose)
o General Purpose
o Special Purpose
Classification of Computers (Size)
o Super Computers
o Mainframe Computers
o Mini Computers
o Micro Computers
 Desktop Computers
 Workstations
 Notebook Computers
 Tablet PCs
 Handheld Computers
 Smartphones
Classification of Computers (Working Mechanism)
o Analog Computers
o Digital Computers
o Hybrid Computers

1. Software
2. Types of Software
a. System Software
i. System Management
ii. System Support
iii. System Development
b. Application Software
i. General Purpose
ii. Application Specific

Lab Manual Page 18 of 104


Computer Programming

LAB 03: CREATING DOCUMENTS WITH ADVANCE


FORMATTING OPERATIONS OF MICROSOFT WORD

Upon successful completion of this lab the students will be able to:
• Insert, format and design the tables in MS Word.
• Insert and format smart art in MS Word.
• Insert symbols and design equations in MS Word.
3. TOOLS
1
• PC with MS Word (Version: 2016, 2013, 2010 or 2007)
3. BACKGROUND
2
3.2.1 Tables in MS Word
A table is a grid of cells arranged in rows and columns. Tables are useful for
various tasks such as presenting text information and numerical data. MS Word
allows you to create and design any type of table. Once created you can merge
multiple cells whether in column or rows to create table with different number of
columns in each row. You can insert a table in word document from Insert tab.

3.2.2 Smart Art


SmartArt allows you to communicate information with graphics instead of just
using text. There are a variety of styles to choose from, which you can use to
illustrate many different types of ideas.

3.2.3 Symbols
Sometimes you may find that you need to add a symbol to your text, such as the
Copyright symbol, ©. Word offers a large collection of symbols for currency,
languages, mathematics, and more.

3.2.4 Equations
MS Equation Editor allows you to design any form of mathematical equation. It
contains many place holders for different operations and bundle of symbols.

Figure 4.1: MS Equation Editor

Lab Manual Page 19 of 104


Computer Programming

3.3 PROCEDURE
3.3.1 Creating a blank table
Step 01: Place your insertion point where you want
the table, then select the Insert tab.
Step 02: Click the Table command.
Step 03: A drop-down menu containing a grid of
squares will appear. Hover the mouse over the grid to
select the number of columns and rows in the table.
Step 04: Click the mouse, and the table will appear in
the document.
Step 05: You can now place the insertion point
anywhere in the table to add text.

3.3.2 Modifying tables

3.3.2.1 To add a row or column

Step 01: Hover the mouse near the location where


you wish to add a row or column and click the plus
sign that appears.
Step 02: A new row or column will appear in the table.
Step 03: Alternatively, you can right-click the table, then hover the mouse over
Insert to see various row and column options.

3.3.2.2 To delete a row or column

Step 01: Place the insertion point in the row or column you want to delete.
Step 02: Right-click the mouse, then select Delete Cells... from the menu that
appears.
Step 03: A dialog box will appear. Select Delete entire row or Delete entire
column, then click OK.

3.3.2.3 To apply a table style

Step 01: Click anywhere on the table, then click the Design tab on the right side
of the Ribbon.
Step 02: Locate the Table Styles group, then click the More drop-down arrow to
see all available table styles.
Step 03: Select the desired style.

Lab Manual Page 20 of 104


Computer Programming

3.3.2.4 Merge and Split Cells

Some tables require a layout that doesn't conform to the standard grid. In those
cases, you may need to merge or split cells.

Merging
Step 01: Bring your mouse pointer position inside the first cell that you want to
merge.
Step 02: Now press the Shift key and click the cells around the cell which you
want to merge into the first cell. This will highlight the cells which you click and
they will be ready to be merged.
Step 03: Now click the Layout tab and then click the Merge Cells button which
will merge all the selected cells.

Splitting
Step 01: Bring your mouse pointer position inside the cell that has to be divided
into multiple cells.
Step 02: Now click the Layout tab and then click the Split Cells button; this will
display a dialog box asking for the number of rows and columns to be created
from the selected cell.
Step 03: Select the desired number of rows and columns that have to go into the
resultant cell and finally click the OK button to apply the result.

3.3.2.5 Splitting a table


Step 01: Bring your mouse pointer position anywhere in the row that should
appear as the first row of the new table.
Step 02: Now click the Layout tab and then click the Split Table button which will
split the table into two tables and the selected row will become the first row of
the lower table.

3.3.3 To insert a SmartArt graphic


Step 01: Place insertion point in the document where you want the SmartArt
graphic to appear. Step 02: From the Insert tab, select the SmartArt command in
the Illustrations group.
Step 03: A dialog box will appear. Select a category on the left, choose the
desired SmartArt graphic, then click OK.

Lab Manual Page 21 of 104


Computer Programming

3.3.3.1 To add text to a SmartArt graphic

Step 01: Select the SmartArt graphic. The SmartArt task pane will appear to the
left.
Step 02: Enter text next to each bullet in the task pane. The text will appear in
the graphic and will resize to fit inside the shape.
Step 03: To add a new shape, press Enter. A new bullet will appear in the task
pane, and a new shape will appear in the graphic. You can delete any bullets
you're not using to remove the shapes.

3.3.3.2 To change the SmartArt layout

Step 01: Select the SmartArt graphic, then select the Design tab.
Step 02: In the Layouts group, click the More drop-down arrow.
Step 03: Select the desired layout, or click More Layouts... to see even more
SmartArt options.

Lab Manual Page 22 of 104


Computer Programming

3.3.4 To insert a symbol


Step 01: Place the insertion point in the location where you want to insert a
symbol.
Step 02: On the Insert tab, click the Symbol drop-down arrow. A menu of symbols
will appear.
Step 03: Select the desired symbol or click More Symbols… if you don’t find

symbol.

3.3.5 To insert an equation


Step 01: Place the insertion point in the location where you want to insert a
symbol.
Step 02: On the Insert tab, click the Equation drop-down arrow. A menu of
equations will appear.
Step 03: Select the desired equation or click Insert New Equation to create it.
Step 04: Click on desired structures and symbols to create the equation.
Step 05: Press enter key when done.

Lab Manual Page 23 of 104


Computer Programming

Lab Manual Page 24 of 104


Computer Programming

EXERCISE
Exercise 3.1: Create the following table in MS Word:

Shopping Bill

Customer Name: Ali

Customer Number: CN2501

S. #. Item Brand Price/Unit Units Price


Oxford Rs. 4500 2 Rs. 9000
1 Dress Pants
Dinners Rs. 2200 1 Rs. 2200

2 Jeans Levis Rs. 5100 2 Rs. 1200

3 Tie Dinners Rs. 550 3 Rs. 1650

Oxford Rs. 3500 1 Rs. 3500

4 Shirt Dinners Rs. 1850 1 Rs. 1850

Cambridge Rs. 4000 1 Rs. 4000

5 Belt Cambridge Rs. 1800 2 Rs. 3600

Total Price Rs. 27000

Discount Rs. 3500

Net Bill Rs. 23500

Lab Manual Page 25 of 104


Computer Programming

Exercise 3.2: Create the following smart art graphics in MS Word:

General Purpose
Purpose
Special Purpose

Super
Desktop
Mainframe
Size Workstation
Classification of
Computers Mini
Notebook
Micro
Tablet
Analog
Handheld
Type of
Data/Working Digital
Mechanism
Smart Phone
Hybrid

Lab Manual Page 26 of 104


Computer Programming

Exercise 3.3: Insert the following equations in MS Word document:

Lab Manual Page 27 of 104


Computer Programming

LAB 04: CREATING AND EDITING MULTIMEDIA


PRESENTATIONS WITH MICROSOFT POWERPOINT

Upon successful completion of this lab the students will be able to:
• Get familiar with MS PowerPoint user interface.
• Create and edit multimedia presentations in MS PowerPoint.
4. TOOLS
1
• PC with MS PowerPoint (Version: 2016, 2013, 2010 or 2007)
4. BACKGROUND
2
4.2.1 MS PowerPoint
PowerPoint 2013 is a presentation software that allows you to create dynamic
slide presentations. Slideshows can include animation, narration, images, videos,
and much more.
Microsoft Office product that provides users with an interface to design
multimedia slides to be displayed on a projection system or personal computer.
The software incorporates images, sounds, videos, text, and charts to create an
interactive presentation. Microsoft PowerPoint interacts with other Office
products such as Microsoft Word and Excel, and is included with most Microsoft
Office packages.

4.2.2 The PowerPoint 2013 Interface


If you've previously used PowerPoint 2010 or 2007, PowerPoint 2013 will feel
familiar. It continues to use features like the Ribbon and the Quick Access
toolbar, where you will find commands to perform common tasks in PowerPoint,
as well as Backstage view.

Lab Manual Page 28 of 104


Computer Programming

Figure 4.1: MS PowerPoint Interface


4.2.3 The Ribbon
PowerPoint 2013 uses a tabbed Ribbon system instead of traditional menus. The
Ribbon contains multiple tabs, each with several groups of commands. You will
use these tabs to perform the most common tasks in PowerPoint.

4.2.3.1 Home Tab

He Home tab gives you access to the most commonly used commands, including
copy and paste, formatting, and the New Slide command.

Figure4 2: Home Tab


.
4.2.3.2 Insert Tab

The Insert tab allows you to insert pictures, charts, tables, shapes, videos and
more, which can help you communicate information visually and add style to
your presentation.

Figure4 3: Insert Tab


.
4.2.3.3 Design Tab

The Design tab allows you to apply themes. A theme is a predefined combination
of colors, fonts, and effects that can quickly change the look and feel of your
entire slide show.

Figure4 4: Design Tab


.

Lab Manual Page 29 of 104


Computer Programming

4.2.3.4 Transitions Tab

The Transitions tab allows you to apply slide transitions. Transitions are the
movements you see between slides when presenting your slide show.

Figure4 5: Transition
s Tab
.
4.2.3.5 Animations Tab

The Animations tab allows you to animate text and objects such as clip art,
shapes and pictures. Animation can be used to draw attention to specific content
or make the slide easier to read.

Figure4 6: Animations Tab


.
4.2.4 Backstage view
Backstage view gives you various options for saving, opening, printing, and
sharing your presentations.

Lab Manual Page 30 of 104


Computer Programming

Figure 4.7: Backstage View


4.2.5. Slide Basics
PowerPoint presentations are made up of a series of slides. Slides contain the
information you will present to your audience. This might include text, pictures,
charts, and more.
Slides have several different layouts for placeholders, depending on the kind of
information you want to include.

Figure4 8: Basic Slide Figure4 9: Slide Layouts


. .

Lab Manual Page 31 of 104


Computer Programming

4.2.6 Themes
A theme is a predefined combination of colors, fonts, and effects. Different
themes also use different slide layouts. Elements of theme are:
Theme Colors: There are 10 theme colors, along with darker and lighter
variations, available from every Color menu.
Theme Fonts: There are two theme fonts available at the top of the Font menu
under Theme Fonts.
Theme Effects: These affect the preset shape styles. You can find shape styles on
the Format tab whenever you select a shape or SmartArt graphic.

4.2.7 Transitions
Transitions are the movements you see between slides when presenting your
slide show. A transition can be as simple as fading to the next slide, or it can be
a flashy, eye-catching effect. PowerPoint makes it easy to apply transitions to
some or all your slides, giving your presentation a polished, professional look.
There are three categories of unique transitions to choose from, all of which can
be found on the Transitions tab:
Subtle: These are the most basic types of transitions. They use simple
animations to move between slides.

Figure 4.10: Subtle Transitions


Exciting: These use more complex animations to transition between slides. While
they're more visually interesting than Subtle transitions, adding too many can
make your presentation look less professional.

Figure 4.11: Exciting Transitions


Dynamic Content: If you're transitioning between two slides that use similar slide
layouts, dynamic transitions will move only the placeholders, not the slides

Lab Manual Page 32 of 104


Computer Programming

themselves. When used correctly, dynamic transitions can help to unify your
slides and add a further level of polish to your presentation.

Figure 4.12: Dynamic Content Transitions


4. PROCEDURE
3
4.3.1 Creating a new presentation
Step 01: Select the File tab to go to Backstage view
Step 02: Select New on the left side of the window, then click Blank Presentation
or choose a theme.
Step 03: A new presentation will appear.

4.3.2 Inserting new slide


Step 01: From the Home tab, click the bottom half of the New Slide command.
Step 02: Choose the desired slide layout from the menu that appears.
Step 03: The new slide will appear. Click any placeholder and begin typing to add
text. You can also click an icon to add other types of content, like a picture or a
chart.
Step 04: To change the layout of an existing slide, click the Layout command,
then choose the desired layout.

4.3.2.1 Managing slides

Step 01: To duplicate slides, select the slide you wish to duplicate, right-click the
mouse, and choose Duplicate Slide from the menu that appears.
Step 02: To move a slide just click, hold, and drag the desired slide in the Slide
Navigation pane to the desired position.
Step 03: To delete a slide simply select the slide you wish to delete, then press
the Delete or Backspace key on your keyboard.

4.3.2.2 Customizing slides

Step 01: To change the slide size, select the Design tab, then click the Slide Size
command. Choose the desired slide size from the menu that appears
(Widescreen 16-by-9 or standard 4by-3)
Step 02: To format slide background, select the Design tab, then click the Format
Background command. Finally select the desired fill options

Lab Manual Page 33 of 104


Computer Programming

Step 03: To apply a theme, select the Design tab on the Ribbon, then click the
More dropdown arrow to see all the available themes. Select the desired theme.

4.3.2.3 Applying Transitions

Step 01: Select the desired slide from the Slide Navigation pane. This is the slide
that will appear after the transition.
Step 02: Click the Transitions tab, then locate the Transition to This Slide group.
By default, None is applied to each slide.
Step 03: Click the More drop-down arrow to display all transitions.
Step 04: Click a transition to apply it to the selected slide. This will automatically
preview the transition.

EXERCISE
Exercise 4.1: Create the following presentation in MS PowerPoint, also apply the
transitions.

Lab Manual Page 34 of 104


Computer Programming

Lab Manual Page 35 of 104


Computer Programming

Lab Manual Page 36 of 104


Computer Programming

Lab Manual Page 37 of 104


Computer Programming

LAB 05: CREATING PRESENTATIONS WITH ADVANCE


OPERATIONS OF MICROSOFT POWERPOINT

Upon successful completion of this lab the students will be able to:
• Insert images, audio, video, WordArt, shapes, tables and charts in
PowerPoint presentation.
• Apply animations to text and objects.
5. TOOLS
1
• PC with MS PowerPoint (Version: 2016, 2013, 2010 or 2007)
5. BACKGROUND
2
5.2.1 Word Art
PowerPoint allows you to add effects to the text inside of a text box, which is
known as WordArt. For the most part, the types of effects you can add are the
same as the ones you can add to shapes and text boxes (shadow, bevel, etc.).
However, with WordArt, you can also Transform the text to give it a wavy,
slanted, or inflated look.

5.2.2 Chart
A chart is a tool you can use to communicate data graphically. Including a chart
in a presentation allows your audience to see the meaning behind the numbers,
which makes it easy to visualize comparisons and trends.

5.2.3 Animating Text and Objects


In PowerPoint, you can animate text and objects such as clip art, shapes, and
pictures. Animation—or movement—on the slide can be used to draw the
audience's attention to specific content or to make the slide easier to read.
There are many different animation effects, you can choose from, and they are
organized into four types:
Entrance: These control how the object enters the slide. For example, with the
Bounce animation the object will "fall" onto the slide and then bounce several
times.

Figure 5.1: Entrance Animations


Emphasis: These animations occur while the object is on the slide, often
triggered by a mouse click. For example, you can set an object to Spin when you
click the mouse.

Lab Manual Page 38 of 104


Computer Programming

Figure 5.2: Emphasis Animations


Exit: These control how the object exits the slide. For example, with the Fade
animation the object will simply fade away.

Figure 5.3: Exit Animations


Motion Paths: These are similar to Emphasis effects, except that the object
moves within the slide along a predetermined path, like a circle.

Figure5 4: Motion Paths Animations


.

5. PROCEDURE
3
5.3.1 Inserting a picture
Step 01: Select the Insert tab, then click the Pictures command in the Images
group.
Step 02: A dialog box will appear. Locate and select the desired image file, then
click Insert.
Step 03: You can also click the Pictures command in a placeholder to insert
images.

5.3.2 Applying WordArt style to a text


Step 01: Select a text box, or select some text
inside of the text box.
Step 02: On the Format tab, click the More drop-
down arrow in the WordArt Styles group.
Step 03: A drop-down menu of WordArt Styles will
appear. Select the style you want to use.

Lab Manual Page 39 of 104


Computer Programming

5.3.3 Inserting a shape


Step 01: Select the Insert tab, then click the Shapes command in the Illustrations
group. A dropdown menu of shapes will appear.
Step 02: Select the desired shape.
Step 03: Click, hold, and drag in the desired location to add the shape to the
slide.

5.3.4 Inserting an audio


Step 01: From the Insert tab, click the Audio drop-down arrow, then select Audio
on My PC.
Step 02: Locate and select the desired audio file, then click Insert.

5.3.5 Inserting an video


Step 01: From the Insert tab, click the Video drop-down arrow, then select Video
on My PC, trim the video's length, add a fade in, and much more.
Step 02: Locate and select the desired video file, then click Insert.

5.3.6 Inserting a blank table


Step 01: From the Insert tab, click the Table command.
Step 02: A drop-down menu containing a grid of squares will appear. Hover the
mouse over the grid to select the number of columns and rows in the table.
Step 03: Click on the slide where you want to place the table. The table will
appear.
Step 04: Click anywhere in the table, and begin typing to add text.
Step 05: You can now place the insertion point anywhere in the table to add text.

5.3.7 Modifying tables


5.3.7.1 To add a row or column

Step 01: Click a cell adjacent to the location where you wish to add a row or
column.
Step 02: Click the Layout tab on the right side of the Ribbon.
Step 03: Locate the Rows & Columns group. If you want to insert a new row,
select either Insert Above or Insert Below. If you want to insert a new column,
select either Insert Left or Insert Right.

Lab Manual Page 40 of 104


Computer Programming

5.3.7.2 To delete a row or column

Step 01: Select the desired row or column by clicking any cell in that row or
column, then select the Layout tab.
Step 02: In the Rows & Columns group, click the Delete command, then select
Delete Rows or Delete Columns from the menu that appears.

5.3.8 To insert a chart


Step 01: Select the Insert tab, then click the Chart command in the Illustrations
group.
Step 02: A dialog box will appear. Select a category from the left pane, and
review the charts that appear in the right pane.
Step 03: Select the desired chart, then click OK.

Step 04: A chart and a spreadsheet will appear. The data that appears in the
spreadsheet is placeholder source data you will replace with your own
information. The source data is used to create the chart.

Step 05: Enter data into the worksheet.

Lab Manual Page 41 of 104


Computer Programming

Step 06: When you're done, click the X to close the spreadsheet.

5.3.8.1 To apply an animation to an object

Step 01: Select the object you want to animate.


Step 02: On the Animations tab, click the More drop-down arrow in the Animation
group.
Step 03: A drop-down menu of animation effects will appear. Select the desired
effect.
Step 04: The effect will apply to the object. The object will have a small number
next to it to show that it has an animation. In the Slide pane, a star symbol also
will appear next to the slide.

5.3.8.2 To add multiple animations to an object

Step 01: Select an object.


Step 02: Click the Animations tab.
Step 03: In the Advanced Animation group, click the Add Animation command to
view the available animations.

Lab Manual Page 42 of 104


Computer Programming

Step 04: Select the desired animation effect.

5.3.8.3 To open the Animation Pane

Step 01: From the Animations tab, click the Animation Pane command.
Step 02: The Animation Pane will open on the right side of the window. It will
show all of the effects for the current slide in the order in which they will appear.
Step 03: If you have several animated objects, it may help to rename the objects
before reordering them in the Animation Pane. You can rename them in the
Selection Pane. To open the Selection Pane, click an object, then from the Format
tab click Selection Pane. Double-click the name of an object to rename it.

5.3.8.4 To change an effect's start option

Step 01: On the Animation Pane, click and drag an effect up or down.
Step 02: The effects will reorder themselves.

Lab Manual Page 43 of 104


Computer Programming

EXERCISE
Exercise 5.1: Create the following presentation in PowerPoint, use animations
and transitions as well.

Lab Manual Page 44 of 104


Computer Programming

Lab Manual Page 45 of 104


Computer Programming

Lab Manual Page 46 of 104


Computer Programming

Lab Manual Page 47 of 104


Computer Programming

LAB 06: CREATING AND EDITING SPREADSHEETS WITH


MICROSOFT EXCEL

Upon successful completion of this lab the students will be able to:
• Get familiar with MS Excel user interface.
• Create and edit spreadsheets in MS Excel.
6. TOOLS
1
• PC with MS Excel (Version: 2016, 2013, 2010 or 2007)
6. BACKGROUND
2
6.2.1 MS Excel
MS Excel is a spreadsheet program that allows you to store, organize, and
analyze information. While you may think that Excel is only used by certain
people to process complicated data, anyone can learn how to take advantage of
Excel's powerful features. Whether you're keeping a budget, organizing a
training log, or creating an invoice, Excel makes it easy to work with different
kinds of data.

6.2.2 The Excel 2013 Interface


When you open Excel 2013 for the first time, the Excel Start Screen will appear.
From here, you'll be able to create a new workbook, choose a template, and
access your recently edited workbooks.
From the Excel Start Screen, locate and select Blank workbook to access the
Excel interface.

Figure 6.1: MS Excel Start Screen

Lab Manual Page 48 of 104


Computer Programming

Figure 6.2: MS Excel User Interface


6.2.3 The Ribbon
Excel 2013 uses a tabbed Ribbon system instead of traditional menus. The
Ribbon contains multiple tabs, each with several groups of commands. You will
use these tabs to perform the most common tasks in Excel.

6.2.3.1 Home Tab

He Home tab gives you access to the most commonly used commands, including
copy and paste, formatting, and number styles.

Figure6 3: Home Tab


.
6.2.3.2 Insert Tab

The Insert tab allows you to insert pictures, charts, tables, sparklines, filers and
more, which can help you visualize and communicate your workbook data
graphically.

Lab Manual Page 49 of 104


Computer Programming

Figure6 4: Insert Tab


.
6.2.3.3 Formulas Tab

The Formulas tab gives you access to the most commonly used functions and
formulas. These commands will help you calculate and analyze numerical data,
like average and percentage..

Figure6 5: FormulaTab
.
6.2.3.4 Data Tab

The Data tab makes it easy to sort and filter information in your workbook, which
can be especially helpful if your project contains large amount of data.

Figure6 6: DataTab
.
6.2.3.5 Worksheet Views

Excel 2013 has a variety of viewing options that change how your workbook is
displayed. You can choose to view any workbook in Normal view, Page Layout
view, or Page Break view. These views can be useful for various tasks, especially
if you're planning to print the spreadsheet.

Figure 6.7: Animations Tab

Lab Manual Page 50 of 104


Computer Programming

6.2.4 Cell Basics


Whenever you work with Excel, you'll enter information, or content, into cells.
Cells are the basic building blocks of a worksheet. You'll need to learn the basics
of cells and cell content to calculate, analyze, and organize data in Excel.

6.2.5 Cell
Every worksheet is made up of thousands of rectangles, which are called cells. A
cell is the intersection of a row and a column. Columns are identified by letters
(A, B, C), while rows are identified by numbers (1, 2, 3).
Each cell has its own name, or cell address, based on its column and row. In this
example, the selected cell intersects column C and row 5, so the cell address is
C5. The cell address will also appear in the Name box. Note that a cell's column
and row headings are highlighted when the cell is selected.

Figure 6.8: Cell


You can also select multiple cells at the same time. A group of cells is known as
a cell range. Rather than a single cell address, you will refer to a cell range using
the cell addresses of the first and last cells in the cell range, separated by a
colon. For example, a cell range that included cells A1, A2, A3, A4, and A5 would
be written as A1:A5.
In the images below, two different cell ranges are selected:
Cell range A1:A8 Cell range A1:B8

Lab Manual Page 51 of 104


Computer Programming

6.2.6 Fill handle


Fill handle allows you to copy contents of one cell to many other cells. It can also
be used to continue a series. Whenever the content of a row or column follows a
sequential order, like numbers (1, 2, 3) or days (Monday, Tuesday, Wednesday),
the fill handle can guess what should come next in the series. In many cases,
you may need to select multiple cells before using the fill handle to help Excel
determine the series order. In our example below, the fill handle is used to
extend a series of dates in a column.

Figure 6.9: Fill handle

6.2.7 Flash fill


A new feature in Excel 2013, Flash Fill can enter data automatically into your
worksheet, saving you a lot of time and effort. Just like the fill handle, Flash Fill
can guess what kind of information you're entering into your worksheet. In the
example below, we'll use Flash Fill to create a list of first names using a list of
existing email addresses.

Figure 6.10: Flash fill


6. PROCEDURE
3
6.3.1 To create a new blank workbook
Step 01: Select the File Tab. Backstage view will appear.
Step 02: Select New, then click Blank workbook.

6.3.2 To manage worksheets


Step 01: To insert new worksheet, locate and select the New sheet button.

Lab Manual Page 52 of 104


Computer Programming

Step 02: To delete a worksheet, right-click the worksheet you wish to delete,
then select Delete from the worksheet menu.
Step 03: To copy a worksheet, right-click the worksheet you want to copy, then
select Move or Copy from the worksheet menu.

6.3.3 To select a cell


Step 01: Click a cell to select it.

Step 02: A border will appear around the selected cell, and the
column heading and row heading will be highlighted. The cell will remain
selected until you click another cell in the worksheet.

6.3.4 To select a range


Step 01: Click, hold, and drag the mouse until all of the adjoining cells you wish
to select are highlighted.
Step 02: Release the mouse to select the desired cell range. The cells will remain
selected until you click another cell in the worksheet.

6.3.5 To delete cells


Step 01: Select the cell(s) you wish to delete.
Step 02: Select the Delete command from the Home tab on the Ribbon.
Step 03: The cells below will shift up.

6.3.6 To use fill handle


Step 01: Select the cell(s) containing the content you wish to use. The fill handle
will appear as a small square in the bottom-right corner of the selected cell(s).
Step 02: Click, hold, and drag the fill handle until all of the cells you wish to fill
are selected.
Step 03: Release the mouse to fill the selected cells.

6.3.7 To use flash fill


Step 01: Enter the desired information into your worksheet. A Flash Fill preview
will appear below the selected cell whenever Flash Fill is available.
Step 02: Press Enter. The Flash Fill data will be added to the worksheet.
Step 03: To modify or undo Flash Fill, click the Flash Fill button next to recently
added Flash Fill data.

Lab Manual Page 53 of 104


Computer Programming

6.3.8 To merge cells using the Merge & Center command


Step 01: Select the cell range you want to merge together.
Step 02: Select the Merge & Center command on the Home tab.
Step 03: The selected cells will be merged, and the text will be centered.

Lab Manual Page 54 of 104


Computer Programming

EXERCISE
Exercise 6.1: Create the following account worksheet in MS Excel:

Exercise 6.2: Create the following simple student test results worksheet in MS
Excel:

Lab Manual Page 55 of 104


Computer Programming

Exercise 6.3: Create the following single-entry bookkeeping cashbooks in MS


Excel:

Lab Manual Page 56 of 104


Computer Programming

LAB 07: CREATING SPREADSHEETS WITH ADVANCE


OPERATIONS OF MICROSOFT EXCEL

Upon successful completion of this lab the students will be able to:
• Insert and create simple and complex formulas in MS Excel.
• Create and use functions in MS Excel.
• Sort and filter the data in MS Excel.
• Create and insert charts in MS Excel worksheets.
7. TOOLS
1
• PC with MS Excel (Version: 2016, 2013, 2010 or 2007)
7. BACKGROUND
2
7.2.1 Formatting text and numbers
One of the most powerful tools in Excel is the ability to apply specific formatting
for text and numbers. Instead of displaying all cell content in exactly the same
way, you can use formatting to change the appearance of dates, times,
decimals, percentages (%), currency ($), and much more.

7.2.2 Simple Formulas


One of the most powerful features in Excel is the ability to calculate numerical
information using formulas. Just like a calculator, Excel can add, subtract,
multiply, and divide. In this lesson, we'll show you how to use cell references to
create simple formulas.

7.2.2.1 Mathematical Formulas

Excel uses standard operators for formulas, such as a plus sign for addition (+), a
minus sign for subtraction (-), an asterisk for multiplication (*), a forward slash
for division (/), and a caret (^) for exponents.
All formulas in Excel must begin with an equals sign (=).
This is because the cell contains, or is equal to, the formula
and the value it calculates.

7.2.2.2 Cell references

While you can create simple formulas in Excel manually


(for example, =2+2 or =5*5), most of the time you will use
cell addresses to create a formula. This is known as
making a cell reference. Using cell references will ensure
that your formulas are always accurate because you can
change the value of referenced cells without having to
rewrite the formula.

Lab Manual Page 57 of 104


Computer Programming

Figure 7.1: Cell references and simple formulas


7.2.3 Complex Formulas
A simple formula is a mathematical expression with one operator, such as 7+9. A
complex formula has more than one mathematical operator, such as 5+2*8.
When there is more than one operation in a formula, the order of operations tells
Excel which operation to calculate first. In order to use Excel to calculate
complex formulas, you will need to understand the order of operations.

7.2.4 Order of operations


Excel calculates formulas based on the following order of operations:

• Operations enclosed in parentheses


• Exponential calculations (3^2, for example)
• Multiplication and division, whichever comes first
• Addition and subtraction, whichever comes first
A mnemonic that can help you remember the order is PEMDAS, or Please Excuse
My Dear Aunt Sally.

7.3 FUNCTIONS
A function is a predefined formula that performs calculations using specific
values in a particular order. Excel includes many common functions that can be
useful for quickly finding the sum, average, count, maximum value, and
minimum value for a range of cells. In order to use functions correctly, you'll

Lab Manual Page 58 of 104


Computer Programming

need to understand the different parts of a function and how to create


arguments to calculate values and cell references.

Figure 7.2: Simple function


7.3.1 Working with arguments
Arguments can refer to both individual cells and cell ranges and must be
enclosed within parentheses. You can include one argument or multiple
arguments, depending on the syntax required for the function.
For example, the function =AVERAGE(B1:B9) would calculate the average of the
values in the cell range B1:B9. This function contains only one argument.
Multiple arguments must be separated by a comma. For example, the function
=SUM(A1:A3, C1:C2, E2) will add the values of all the cells in the three
arguments.

Figure 7.3: Function arguments


Excel has a variety of functions available. Here are some of the most common
functions you'll use:

• SUM: This function adds all of the values of the cells in the argument.
• AVERAGE: This function determines the average of the values included in
the argument. It calculates the sum of the cells and then divides that
value by the number of cells in the argument.
• COUNT: This function counts the number of cells with numerical data in
the argument.
This function is useful for quickly counting items in a cell range.
• MAX: This function determines the highest cell value included in the
argument.
• MIN: This function determines the lowest cell value included in the
argument.

Lab Manual Page 59 of 104


Computer Programming

7.3.2 The Function Library


While there are hundreds of functions in Excel, the ones you use most frequently
will depend on the type of data your workbooks contains. There is no need to
learn every single function, but exploring some of the different types of functions
will be helpful as you create new projects. You can search for functions by
category, such as Financial, Logical, Text, Date & Time, and more from the
Function Library on the Formulas tab.
To access the Function Library, select the Formulas tab on the Ribbon. The
Function Library will appear.

7.4 SORTING DATA


As you add more content to a worksheet, organizing that information becomes
especially important. You can quickly reorganize a worksheet by sorting your
data. For example, you could organize a list of contact information by last name.
Content can be sorted alphabetically, numerically, and in many other ways.
When sorting data, it's important to first decide if you would like the sort to apply
to the entire worksheet or just a cell range.
Sort sheet organizes all of the data in your worksheet by one column. Related
information across each row is kept together when the sort is applied. In the
example below, the Contact Name column (column A) has been sorted to display
the names in alphabetical order.
Sort range sorts the data in a range of cells, which can be helpful when working
with a sheet that contains several tables. Sorting a range will not affect other
content on the worksheet.

7.5 FILTERING DATA


If your worksheet contains a lot of content, it can be difficult to find information
quickly. Filters can be used to narrow down the data in your worksheet, allowing
you to view only the information you need.

7.6 CHARTS
It can often be difficult to interpret Excel workbooks that contain a lot of data.
Charts allow you to illustrate your workbook data graphically, which makes it
easy to visualize comparisons and trends.
Excel has several different types of charts, allowing you to choose the one that
best fits your data. In order to use charts effectively, you'll need to understand
how different charts are used.
In addition to chart types, you'll need to understand how to read a chart. Charts
contain several different elements, or parts, that can help you interpret the data.

7. PROCEDURE
7
7.7.1 To apply number formatting
Step 01: Select the cells(s) you wish to modify.

Lab Manual Page 60 of 104


Computer Programming

Step 02: Click the drop-down arrow next to the Number Format command on the
Home tab. The Number Formatting drop-down menu will appear.
Step 03: Select the desired formatting option. In our example, we will change the
formatting to Long Date.
Step 04: The selected cells will change to the new formatting style. For some
number formats, you can then use the Increase Decimal and Decrease Decimal
commands (below the Number Format command) to change the number of
decimal places that are displayed.

7.7.2 To create a formula


Step 01: Select the cell that will contain the formula. In our example, we'll select
cell B3.

Step 02: Type the equals sign (=). Notice how it appears in both the cell and the
formula bar.
Step 03: Type the cell address of the cell you wish to reference first in the
formula: cell B1 in our example. A blue border will appear around the referenced
cell.
Step 04: Type the mathematical operator you wish to use. In our example, we'll
type the addition sign (+).
Step 05: Type the cell address of the cell you wish to reference second in the
formula: cell B2 in our example. A red border will appear around the referenced
cell.
Step 06: Press Enter on your keyboard. The formula will be calculated, and the
value will be displayed in the cell.

7.7.3 To create a formula using the point-and-click method


Step 01: Select the cell that will contain the formula. In our example, we'll select
cell D3.

Lab Manual Page 61 of 104


Computer Programming

Step 02: Type the equals sign (=).


Step 03: Select the cell you wish to reference first in the formula: cell B3 in our
example. The cell address will appear in the formula, and a dashed blue line will
appear around the referenced cell.
Step 04: Type the mathematical operator you wish to use. In our example, we'll
type the multiplication sign (*).
Step 05: Select the cell you wish to reference second in the formula: cell C3 in
our example. The cell address will appear in the formula, and a dashed red line
will appear around the referenced cell.
Step 06: Press Enter on your keyboard. The formula will be calculated, and the
value will be displayed in the cell.

7.7.4 To create a complex formula


Step 01: Select the cell that will contain the formula. In our example, we'll select
cell C4.

Step 02: Enter your formula. In our example, we'll type =B2*C2+B3*C3. This
formula will follow the order of operations, first performing the multiplication:
2.29*20 = 45.80 and 3.49*35 = 122.15. Then, it will add those values together
to calculate the total: 45.80+122.15.
Step 03: Double-check your formula for accuracy, then press Enter on your
keyboard. The formula will calculate and display the result. In our example, the
result shows that the total cost for the order is $167.95.

Lab Manual Page 62 of 104


Computer Programming

7.7.5 To create a basic function


Step 01: Select the cell that will contain the function. In our example, we'll select
cell C11.

Step 02: Type the equals sign (=) and enter the desired function name. You can
also select the desired function from the list of suggested functions that will
appear below the cell as you type. In our example, we'll type =AVERAGE.
Step 03: Enter the cell range for the argument inside parentheses. In our
example, we'll type (C3:C10). This formula will add the values of cells C3:C10
and then divide that value by the total number of cells in the range to determine
the average.
Step 04: Press Enter on your keyboard. The function will be calculated, and the
result will appear in the cell. In our example, the average price per unit of items
ordered was $15.93.

7.7.6 To create a function using the AutoSum command


Step 01: Select the cell that will contain the function. In our example, we'll select
cell D12.

Step 02: In the Editing group on the Home tab, locate and select the arrow next
to the AutoSum command and then choose the desired function from the drop-
down menu. In our example, we'll select Sum.

Lab Manual Page 63 of 104


Computer Programming

Step 03: The selected function will appear in the cell. If logically placed, the
AutoSum command will automatically select a cell range for the argument. In our
example, cells D3:D11 were selected automatically and their values will be
added together to calculate the total cost. You can also manually enter the
desired cell range into the argument.
Step 04: Press Enter on your keyboard. The function will be calculated, and the
result will appear in the cell. In our example, the sum of D3:D11 is $606.05.

7.7.7 To insert a function from the Function Library


Step 01: Select the cell that will contain the function. In our example, we'll select
cell D3.

Step 02: Click the Formulas tab on the Ribbon to access the Function Library.
Step 03: From the Function Library group, select the desired function category.
In our example, we'll choose Date & Time.
Step 04: Select the desired function from the drop-down menu. In our example,
we'll select the NETWORKDAYS function to count the number of business days
between the ordered date and received date.
Step 05: The Function Arguments dialog box will appear. From here, you'll be
able to enter or select the cells that will make up the arguments in the function.
In our example, we'll enter B3 in the Start_date: field and C3 in the End_date:
field.
Step 06: When you're satisfied with the arguments, click OK.
Step 07: The function will be calculated, and the result will appear in the cell. In
our example, the result shows that it took four business days to receive the
order.

7.7.8 To sort a sheet


Step 01: Select a cell in the column you wish to sort by. In our example, we'll
select cell C2.

Lab Manual Page 64 of 104


Computer Programming

Step 02: Select the Data tab on the Ribbon, then click the Ascending command
sort ascending to Sort A to Z, or the Descending command sort ascending to Sort
Z to A. In our example, we'll click the Ascending command.
Step 03: The worksheet will be sorted by the selected column. In our example,
the worksheet is now sorted by last name.

7.7.9 To sort a range


Step 01: Select the cell range you wish to sort. In our example, we'll select cell
range A13:B17.

Step 02: Select the Data tab on the Ribbon, then click the Sort command.
Step 03: The Sort dialog box will appear. Choose the column you wish to sort by.
In our example, we want to sort the data by the number of T-shirt orders, so we'll
select Orders.
Step 04: Decide the sorting order (either ascending or descending). In our
example, we'll use Smallest to Largest.
Step 05: Once you're satisfied with your selection, click OK.
Step 06: The cell range will be sorted by the selected column. In our example,
the Orders column will be sorted from lowest to highest. Notice that the other
content in the worksheet was not affected by the sort.

Lab Manual Page 65 of 104


Computer Programming

7.7.10 To filter data


Step 01: Select the Data tab, then click the Filter command.

Step 02: A drop-down arrow will appear in the header cell for each column.
Step 03: Click the drop-down arrow for the column you wish to filter. In our
example, we will filter column B to view only certain types of equipment.
Step 04: The Filter menu will appear.
Step 05: Uncheck the box next to Select All to quickly deselect all data.
Step 06: Check the boxes next to the data you wish to filter, then click OK. In this
example, we will check Laptop and Tablet to view only those types of equipment.
Step 07: The data will be filtered, temporarily hiding any content that doesn't
match the criteria. In our example, only laptops and tablets are visible.

7.7.11 To insert a chart


Step 01: Select the cells you want to chart, including the column titles and row
labels. These cells will be the source data for the chart. In our example, we'll
select cells A1:F6.

Step 02: From the Insert tab, click the desired Chart command. In our example,
we'll select Column.

Lab Manual Page 66 of 104


Computer Programming

Step 03: Choose the desired chart type from the drop-down menu.
Step 04: The selected chart will be inserted in the worksheet.

Lab Manual Page 67 of 104


Computer Programming

EXERCISE
Exercise 7.1: Create the following worksheet for marksheet generation:

Exercise 7.2: Create the following worksheet for implementing general


formulas:

Lab Manual Page 68 of 104


Computer Programming

Exercise 7.3: Create the following business worksheet:

Exercise 7.4: Create the following worksheet and insert bar charts:

Lab Manual Page 69 of 104


Computer Programming

Exercise 7.5: Create the following worksheet and insert pie chart:

Lab Manual Page 70 of 104


Computer Programming

Exercise 7.6: Create the following worksheet and insert scattered charts:

Lab Manual Page 71 of 104


Computer Programming

LAB-08: WORKING WITH MICROSOFT DISK OPERATING


SYSTEM (MS-DOS)

Upon successful completion of this lab the students will be able to:
• Get familiar with Disk Operating System (DOS) Command Line Interface.
• Understand the syntax and execute MS DOS commands.

8.1 TOOLS
•  PC with MS-DOS or Command Prompt.
8.1 BACKGROUND
8.2.1 MS-DOS
Short for Microsoft Disk Operating System, MS-DOS is a non-graphical command
line operating system created for IBM compatible computers. MS-DOS was first
introduced by Microsoft in August 1981 and was last updated in 1994 with MS-
DOS 6.22.

8.2.2 Windows Command Line


Today, MS-DOS is no longer used; however, the command shell, more commonly
known as the Windows command line is still used by many users. Most computer
users are only familiar with how to navigate Microsoft Windows using the mouse.
Unlike Windows, MS-DOS is a command-line and is navigated by using MS-DOS
commands.

Figure 8.1: Windows command prompt

8.2.3 MS-DOS Commands


There are two types of MS-DOS commands:

• Internal Commands
• External Commands

Lab Manual Page 72 of 104


Computer Programming

8.2.8.1 Internal Commands


These commands do not require any special files for being executed. They are
part of COMMAND.com file. They are brought into the computer's memory as
soon as the computer is switched on.
For example: COPY, DEL, DIR, TYPE, CD, MD, CLS, DATE, TIME and PATH.

8.2.8.2 External Commands


These commands require certain special DOS files to get executed. They are not
the part of COMMAND.com file. They are not loaded in to the memory when
computer turns on.
For example: CHKDSK, XCOPY, DELTREE, DISKCOPY, etc.

8.2.4 Common MS DOS Commands

S.NO Command Description Syntax


.
CHDIR [/D][drive:][path]
Displays the name of or CHDIR [..]
1 CD CD [/D] [drive:][path]
changes the current directory.
CD [..]
2 CLS Clears the screen CLS
COLOR [attr]

Color attributes are


specified by TWO hex
digits -- the first
corresponds to the
background; the second
the foreground. Each
Sets the default console digit can be any of the
3 COLOR foreground and background following values:
colors.
0=Black 8=Gray
1=Blue 9=Light Blue
2=Green A=Light Green
3=Aqua B=Light Aqua
4=Red C=Light Red
5=Purple D=Light Purple
6=Yellow E=Light Yellow
7=White F=Bright White
COPY [/D] [/V] [/N] [/Y
| /-Y] [/Z] [/L] [/A
Copies one or more files to | /B ] source [/A | /B]
4 COPY [+ source [/A | /B] [+
another location.
...]] [destination [/A |
/B]]
5 DATE Displays or sets the date. DATE [/T | date]
DEL [/P] [/F] [/S]
6 DEL Deletes one or more files. [/Q]
[/A[[:]attributes]]

Lab Manual Page 73 of 104


Computer Programming

names
ERASE [/P] [/F] [/S] [/Q]
[/A[[:]attributes]] names

DIR
[drive:][path][filename]
[/A[[:]attributes]] [/B]
Displays a list of files and [/C] [/D] [/L] [/N]
7 DIR [/O[[:]sortorder]] [/P]
subdirectories in a directory.
[/Q] [/R] [/S]
[/T[[:]timefield]] [/W]
[/X] [/4]
Quits the CMD.EXE program
8 EXIT (command interpreter) or the EXIT [/B] [exitCode]
current batch script.
Provides help information for
9 HELP HELP [command]
windows commands.
Creates, changes, or deletes the LABEL [drive:][label]
10 LABEL volume label of a disk. LABEL [/MP] [volume]
[label]
11 MD Creates a directory. MKDIR [drive:]path MD
[drive:]path
Moves files and renames files MOVE [/Y | /-Y] [drive:]
12 MOVE and directories. [path]dirname1 dirname2

RMDIR [/S] [/Q]


[drive:]path RD
13 RD Removes (deletes) a directory. [/S] [/Q]
[drive:]path
RENAME
[drive:][path]filename1
filename2.
14 REN Renames a file or files. REN
[drive:][path]filename1
filename2.
15 TIME Displays or sets the system TIME [/T | time]
time.
Graphically displays the folder TREE [drive:][path] [/F]
16 TREE [/A]
structure of a drive or path.
17 VER Displays the Windows version. VER
Note: text inside square brackets [ ] specified in syntax is optional. For any detail
of the command type HELP space command name e.g. HELP DIR

8.2.5 Wildcard characters


Symbol used to replace or represent one or more characters. Wildcards or wild
characters are either an asterisk (*), which represents one or more characters or
question mark (?), which represents a single character. In the examples below of
how a wildcard may be used, realize that wildcards are relatively universal. This
means an example in DOS is similar to how it would be used in Linux, with the
exception being that the command may be different.

Lab Manual Page 74 of 104


Computer Programming

Listing files in MS-DOS that contain c, mp, and any other character in-between.
For example, comp, camp, c2mp, and c-mp would all be matched.
dir c?mp

In this next example the dir command would only list files that end with .MP3 file
extension. dir *.mp3

List any file that ends with data. For example, appdata, mydata, and 123data
would all be matched. dir *data

List any file that is four characters long, begins with he, and has any extension.
For example, help.txt, help.mp3, and heck.jpg would all be matched.
dir he??.*

Rename all files in the current directory that end with the file extension .txt
to .jpg. For example, the file test.txt would become test.jpg.
rename *.txt *.jpg

Deleting files in MS-DOS that begin with comp and end with a .txt extension.
del comp*.txt

Linux and Unix


Listing files in a Linux variant or Unix variant that begin with comp.
ls comp*

Deleting files in a Linux or Unix variant that contain c, mp, and any character in-
between.
rm c?mp

8. PROCEDURE
3
8.3.1 How to open command prompt
Step 01: Click Start button OR open Run dialog box by pressing StartKey+R on
the keyboard.
Step 02: Type cmd and press enter.
Step 03: Command window will appear.
Note:
Typically command prompt starts you at your user directory. In the example
below, the user is Ali, so our prompt is C:\Users\Ali>.

Lab Manual Page 75 of 104


Computer Programming

Figure 8.2: Current user prompt

8.3.2 How to enter command


Step 01: Open the command prompt.
Step 02: Check the syntax of command by typing HELP command_name.
Step 03: Write down the command and press enter key.
Step 04: The console will display the output of the command.

Example: Display all dll files from C:\WInsows\System32 folder.

Command: DIR C:\Windows\System32\*.dll

Lab Manual Page 76 of 104


Computer Programming

EXERCISE
Exercise 8.1: Write MS DOS commands for the followings (Use wildcard
Characters).

a) Change the current directory to C:\Windows\System32\


_____________________________________________________________________________
_______________
b) Display all files whose name begin with “a”
_____________________________________________________________________________
_______________
c) Display all files whose name end with “a”
_____________________________________________________________________________
_______________
d) Display all files whose name contain “a”
_____________________________________________________________________________
_______________
e) Display all files whose name contain “a” and “b”
_____________________________________________________________________________
_______________
f) Display all files whose extension start with “d”
_____________________________________________________________________________
_______________
g) Display all the files whose name contain “c” and extension of “.exe”
_____________________________________________________________________________
_______________
h) Display all files whose name contain 2 letters
_____________________________________________________________________________
_______________
i) Display all “.exe” files whose name contain 2 letters
_____________________________________________________________________________
_______________
j) Display all files whose extension contain 2 letters
_____________________________________________________________________________
_______________

Exercise 8.2: Write MS DOS commands for the followings

a) Change the current directory to C:\Windows\System\

Lab Manual Page 77 of 104


Computer Programming

_____________________________________________________________________________
_______________
b) Create three folders named Folder1, Folder2 and Folder3 in your D:
_____________________________________________________________________________
_______________

c) Copy files, file1.txt and file2.txt to Folder2


_____________________________________________________________________________
_______________ d) Move Folder2 in to Folder3
_____________________________________________________________________________
_______________
e) Rename Folder1 to MyFolder
_____________________________________________________________________________
_______________
f) Move Folder3 in to MyFolder
_____________________________________________________________________________
_______________ g) Delete MyFolder
_____________________________________________________________________________
_______________
h) View all hidden files in D:\MyFolder\Folder3
_____________________________________________________________________________
_______________
i) Create the folders named TextFiles, EXEFiles and BMPFiles in to D:
_____________________________________________________________________________
_______________
j) Copy all text files from C:\Windows\System32 in to D:\TextFiles
_____________________________________________________________________________
_______________
k) Copy all exe files from C:\Windows\System32 in to D:\EXEFiles
_____________________________________________________________________________
_______________
l) Copy all bmp files from C:\Windows\System32 in to D:\BMPFiles
_____________________________________________________________________________
_______________
m) Create a folder D:\Dummy
_____________________________________________________________________________
_______________

Lab Manual Page 78 of 104


Computer Programming

n) Copy all text files (whose name begin with a) from C:\Windows\System32 in
to
D:\Dummy
_____________________________________________________________________________
_______________
o) Copy all text files (whose name begin with ab) from C:\Windows\System32 in
to
D:\Dummy
_____________________________________________________________________________
_______________
p) Copy all files (whose name begin with z) from C:\Windows\System32 in to D:\
Dummy
_____________________________________________________________________________
_______________
q) Copy all files (whose name begin with b and end with b) from C:\Windows\
System32 in to D:\Dummy
_____________________________________________________________________________
_______________
r) Delete all files from D:\Dummy whose extension start with a
_____________________________________________________________________________
_______________
s) Delete all files from D:\Dummy whose name start with a extension start with
z
_____________________________________________________________________________
_______________
t) Delete all files from D:\Dummy whose name contain aa in their name
_____________________________________________________________________________
_______________
u) Delete the entire directory D:\Dummy
_____________________________________________________________________________
_______________
v) Quick Format USB drive (Write drive letter according to USB drive letter
assigned in your
PC)
_____________________________________________________________________________
_______________
w) Change the label of D: to MyDrive
_____________________________________________________________________________
_______________

Lab Manual Page 79 of 104


Computer Programming

x) Change USB drive label to CF USB


_____________________________________________________________________________
_______________
y) Check the memory of the PC
_____________________________________________________________________________
_______________
z) Close the Command prompt window
_____________________________________________________________________________
_______________

Lab Manual Page 80 of 104


Computer Programming

LAB-08: GETTING FAMILIAR WITH FUNDAMENTALS OF


PROGRAMMING USING C++

Upon successful completion of this lab the students will be able to:
• Getting familiar with basics of C++ programming language.
• Understanding and be able to write and debug simple program in C++.
• Understanding the concept of variable, data types and operators in C++.

TOOLS
 Code::Blocks (Version: 13.12) or Bloodshed Dev C++ (Version: 4, 5 or
higher)
9.1 INTRODUCTION
9.1.1 C++ Programming Language
C++ (pronounced "see plus plus") is a general-purpose Object Oriented
Programming language with high-level and low-level capabilities. It is a statically
typed, free-form, multi-paradigm, usually compiled language supporting
procedural programming, data abstraction, object-oriented programming, and
generic programming. C++ is regarded as a mid-level language. This indicates
that C++ comprises a combination of both high-level and low-level language
features.
Bjarne Stroustrup developed C++ in 1979 at Bell Labs as an enhancement to the
C programming language and named it "C with Classes". In 1983 it was renamed
to C++. Enhancements started with the addition of classes, followed by, among
other features, virtual functions, operator overloading, multiple inheritance,
templates, and exception handling. The C++ programming language standard
was ratified in 1998 as ISO/IEC 14882:1998, the current version of which is the
2003 version, ISO/IEC 14882:2003. A new version of the standard (known
informally as C++0x) is being developed.

9.1.2 History of C++


Stroustrup began work on C with Classes in 1979. The idea of creating a new
language originated from Stroustrup's experience in programming for his Ph.D.
thesis. Stroustrup found that Simula had features that were very helpful for large
software development, but the language was too slow for practical use, while
BCPL was fast but too low-level and unsuitable for large software development.
When Stroustrup started working in Bell Labs, he had the problem of analyzing
the UNIX kernel with respect to distributed computing. Remembering his Ph.D.
experience, Stroustrup set out to enhance the C language with Simula-like
features. C was chosen because it is general-purpose, fast, and portable. Besides
C and Simula, some other languages which inspired him were ALGOL 68, Ada,
CLU and ML. At first, the class, derived class, strong type checking, inlining, and
default argument features were added to C via Cfront. The first commercial
release occurred in October 1985.
In 1983, the name of the language was changed from C with Classes to C++.
New features were added including virtual functions, function name and

Lab Manual Page 81 of 104


Computer Programming

operator overloading, references, constants, usercontrolled free-store memory


control, improved type checking, and BCPL style single-line comments with two
forward slashes (//). In 1985, the first edition of The C++ Programming
Language was released, providing an important reference to the language, as
there was not yet an official standard. In 1989, Release 2.0 of C++ was
released. New features included multiple inheritance, abstract classes, static
member functions, const member functions, and protected members. In 1990,
The Annotated C++ Reference Manual was published. This work became the
basis for the future standard. Late addition of features included templates,
exceptions, namespaces, new casts, and a Boolean type.
As the C++ language evolved, a standard library also evolved with it. The first
addition to the C++ standard library was the stream I/O library which provided
facilities to replace the traditional C functions such as printf and scanf. Later,
among the most significant additions to the standard library, was the Standard
Template Library.

9.1.3 Code::Blocks
Code::Blocks is a free, open source cross-platform IDE which supports multiple
compilers including GCC, Clang and Visual C++. It is developed in C++ using
wxWidgets as the GUI toolkit. Using a plugin architecture, its capabilities and
features are defined by the provided plugins. Currently, Code::Blocks is oriented
towards C, C++, and Fortran. It has a custom build system and optional Make
support.
Code::Blocks is being developed for Windows, Linux, and Mac OS X and has been
ported to FreeBSD, OpenBSD and Solaris. Statements are executed on the basis
of conditions.

Lab Manual Page 82 of 104


Computer Programming

9.1.4 Basic C++ Program


Program (basic.cpp)

The program starts with the two lines containing a pound sign (#) and the
keyword include. These are known as preprocessor directives. The preprocessor
directives are the instructions to the part of the compiler known as preprocessor
which includes some extra files (codes) to the basic source program. The files
iostream and conio.h are known as the header files which contain the definitions
of some functions. The iostream header file contains the definition of standard
input/output streams like, cout and cin where as conio.h header file includes the
definitions of function getch(), getche() and others. Simply speaking the
preprocessor directive #include is responsible for including the contents of the
header files into the source file.

using namespace std enables a program to use all the names in any standard C++
header (such as <iostream>) that a program might include.

The main() is the function as the function is always along with the parentheses.
The main() function is the first executable function in any C++ program. No
matter where the main() function is located always the first precedence goes to
the main() function and its contents. The contents of main function are enclosed
in curly braces. The void before the main function says that the function main
has no return type value and at the end of the function main() will not return any
value.

The braces “{ “and “}” also known as curly braces, enclose the block of code
present in any function. “{“ is known as the opening brace and ”}” is known as
closing brace. Opening brace shows the starting of the main or any function and
closing brace shows the ending of the main or any function. The code of each
and every function is always enclosed in the curly braces.

The cout<<”My name is Ali Asghar” tells the computer to print the string constant
“My name is Ali Asghar” on the console screen. The cout is the standard output
stream which directs the flow of data to the console screen. What ever written in
the double quotations in cout statement is printed as it is on the console screen.
Every C++ statement must end with a semicolon (also known as the statement
terminator). Preprocessor directives (like #include) do not end with a semicolon.

The getch() (get character) function waits to get the character from keyboard. If
you run your program without using getch() your program will show the result in
just one blink and will vanish out quickly. So to make the output console screen

Lab Manual Page 83 of 104


Computer Programming

stop in order to examine the results clearly we use getch() function. The
definition of the function getch() is present in the header file “conio.h”.
When the return statement is used at the end of main, the value 0 indicates that
the program has terminated successfully. According to the C++ standard, if
program execution reaches the end of main without encountering a return
statement, it’s assumed that the program terminated successfully— exactly as
when the last statement in main is a return statement with the value 0. For that
reason, we omit the return statement at the end of main in subsequent
programs.
The output of basic.cpp on the console screen may look like as shown in below
figure:

9.1.5 Functions
Functions are the one of the fundamental building blocks of C++ language. The
functions are the sub programs which contain some block of code inside the
curly braces. The code enclosed inside the curly braces is known as the body of
the function. The functions always start with the return type and the function
name followed by the parenthesis. The parentheses tell the compiler that it is a
function not a variable or any other thing. Sometimes the parentheses also
contain arguments, which are the values that the function passes through its
body. As the statements are the instructions to the compiler and they are just
executed from the place where they are placed but if we want to execute the
same block of statements at different places according to the situations of the
program then the function is way which provides us the facility to execute that
same block of statements (codes) at different places. The block of code present
in any function can be executed at any place by calling that function at that
point in the program. Any C++ program can contain number of functions or at
least one i.e. main(). All the C++ programs always contain the main() function,
because it is the gateway to enter in C++ and no program can run with out
main() function.
In basic.cpp, the main() is only the function present. It contains the block of
three line code. This three line code present in main() is always executed first in
this program, because the contents of the main() functions have the highest
precedence as compared to the contents of other functions.

Lab Manual Page 84 of 104


Computer Programming

9.1.6 Statements
Statements are the instructions to the computer to work accordingly. All the
statements are always terminated with the terminator “;”. This semicolon is
known as terminator because it terminates the statement and tells the compiler
that the statement has ended. If we don’t give the terminator at the end of any
statement, the compiler will think that the statement is still going on and will
mix another statement or code with it hence giving an error. In basic.cpp, there
is only one statement cout<<”My name is Ali Asghar”; it just tells the computer
to print the string constant present in quotation marks on the console screen. So
every statement is the instruction to the computer and do remember to place
the terminator at the end of each and every statement.

9.1.7 Preprocessor Directives and the Header Files


The preprocessor directives are the instruction to the part of the compiler known
as preprocessor. These preprocessor directives give the direction to the compiler
before compiling any source code. The preprocessor directive #include is used
to include the block of code of header files in to any source program without
writing the whole block of code of that header file. The #include preprocessor
directive provides you the facility to include thousands of lines of code of the
header files into your source program. On the other hand the header files are
the files with the extension .h present in the INCLUDE directory of your C++
software. These header files are the files which contain the definitions of certain
functions of C++. As discussed earlier that a computer is just a dumb machine
which cannot understand anything and is unfamiliar to the words like cout, cin,
return, void, main etc. So in order to make the computer know what these words
are we use header files, which contain the instructions to the computer that tells
it how to act when it faces these kinds of codes. Now we have made the
computer understand these words but the problem is this the instruction to
make it understand are made in thousands of lines of codes so we cannot do
such a lengthy process of writing thousands of line of codes for each tiny or long
program. To overcome this major problem we can include the entire block of
code present in any header file into our source file by just writing a single line
statement i.e. #include <headerfilename.h>. In this way we are released from
passing through such a lengthy and complex problem and we feel calm to have
this feature.

The preprocessor directives are always started with the “#” (hash/pound) sign
which tells the compiler that the thing that you are compiling is a preprocessor
directive which is different from other. And the header files are always enclosed
in “< >” angle brackets following the keyword include but in some cases it is
enclosed in double quotation marks. If you enclose the header file in the angle
brackets it will start the search for the header file in the standard INCLUDE
directory.
#include <iostream>

But when you want to include the user defined header file the header file is
enclosed in quotation marks.
#include “ali.h”

Lab Manual Page 85 of 104


Computer Programming

The quotation marks tells the compiler to start the search for the header file in
the current directory—the directory usually containing the source files.
In basic.cpp, there are two header files included in the source program. One is
iostream which contains the definitions of standard input and output streams
like, cout and cin. The other header file is conio.h which contains the basic
definition of the functions like, getch(), getche(), etc.

9.1.8 Standard Input and Output Streams


The term stream means the flow of the data. The data flown towards the system
through the input devices is known as input stream whereas the data flown from
the system to some output devices is known as output stream. The standard
input stream is flown from the keyboard to the system and the standard output
stream is flown from the system to the console screen. In order to control this
flow of data to and from the system there are two statements used. The first
“cout” which controls the standard output stream and the other “cin” which
controls the standard input stream. The definitions of both the keywords is
written in the header file iostream (input/output stream), so to get access to
these statements you must first include the header file iostream in your source
program.

9.1.9 Outputting with cout


The identifier cout is actually an object which is predefined in C++. The cout
statement is responsible for displaying the text, numbers and some special
characters and graphical symbols on the console screen. The simplest structure
of cout statement is given as:
cout<<”My name is Ali Asghar”;

In above syntax the keyword cout tells the compiler that it is a standard output
stream and treat it as accordingly. The text in the double quotation marks ”My
name is Ali Asghar” is the string constant and is printed on the console screen as
it is. The operator << is known as insertion or put to operator. It directs the
contents of the variable on its right to the object on its left. The insertion
operator can be used multiple times in single cout statement and it is perfectly
legal as in below statement:
cout<<”My name is “<<”Ali Asghar”;

Except printing the string constants, the situation also come in which we have to
print out the values of certain variables on the console screen then we can use
the variable name in cout statement to print its value on the console screen as
in below statement:
cout<<”The addition of two numbers is: “<<Add;

To make the variable Add effective in cout statement it should be declared and
defined properly in the program. You can also print the values of several
variables in using cout statement as in below statement, which prints the
number of apples and oranges in the box.

Lab Manual Page 86 of 104


Computer Programming

cout <<”There are “<<a<<”apples”<<”and “<<b<<”oranges in the box”;

As the cout is a statement therefore each and every cout statement should be
terminated with the terminator “;”. Let’s examine the following program:

The above program’s code contain three cout statements. The first cout
statement prints the string constant “My name is Ali Asghar.” on the screen as it
is where as “\n” is the escape sequence which moves the cursor to the new line
so that the coming line will be printed on the fresh line. Then the next cout
statement flows the string constant ”I teach at CSE department.”; to the console
screen on the new line. In the last cout statement we face a new unfamiliar word
endl, it is known as the manipulator. The manipulators are the instructions to the
output stream which modify or manipulate the way the data is displayed in the
console screen. The manipulator endl has the same effect of causing a linefeed
as the \n has but it is somewhat clearer. The endl manipulator also causes the
buffer to be flushed. So, on conclusion the third cout statement in SOS.cpp, flows
the string constant ”I live in Jamshoro.” to the console screen on new line.

9.1.10 Inputting with cin


The identifier cin is an object which is predefined in C++. The cin statement is
responsible for getting input and passing for processing during the run-time. The
simplest structure of cin statement is:
cin>>number;

Lab Manual Page 87 of 104


Computer Programming

In above syntax the keyword cin tells the compiler that it is a standard input
stream and treat it as accordingly. The operator >> is known as extraction or
get from operator. It takes the value from stream object on its left and places it
in the variable on its right. Let’s examine the following program

The above program first initializes that the variables a, b and Ans contain the
integer data type values. The first cout statement sends the message to enter
first number from your keyboard and when you enter any number, the cin
statement places that number in the variable a. Then the program gives another
message to enter second number and when you enter any number that will be
placed in the variable b. The statement Ans=a+b then adds the two numbers
and places the result in the variable Ans. Finally the last cout statement shows
the addition of both numbers.

9.1.11 Comments
Commenting is very effective feature in any programming language as it makes
the source program user friendly up to some extent. Comments are un-
executable lines in any source program. Comments make the program more
readable and understandable to the user or even an unknown reader. They help
the programmer to make him remember that for this purpose you have written
this portion of code. And also if a person is unfamiliar with the program, the
comments will help him by telling him what is happening in a certain line or
portion of the program. When you write a program and suppose you are not in

Lab Manual Page 88 of 104


Computer Programming

touch with it for a two or three months so when you come back to your program
after such a long period you will forget that for what I had written it and what it
tell? So if you had given the comments in your program you would not be in such
a great trouble.
In small programs it is not a huge problem to forget some code lines but in case
of working on some programs having hundreds or thousands of code line or
working on a project you have to deal with several different blocks of codes so,
in these situations there are a lot of chances to forget the construction of your
own program. So here the comments play their key role.
There are two ways to comment in C++ source file. The first way it to start
comment with the two back slashes “//” , this causes the compiler to consider
the whole line as a comment. The other way is to start the comment with a back
slash and an asterisk “/*” and terminate the comment with an asterisk and back
slash “*/”, which cause the certain block of line as a comment.
The first way only make a single line as a comment but if we want to make the
100 lines as the comment then we can not use the double backslashes “//”
hundred of times. But at this situation the second way suites very well in which
we will place “/*” the starting of the comment and “*/” at the ending of the
comment.
Examine the following program:

9.1.12 Variables
The basic definition of the variable says that the variables are those memory
locations whose value can be varied/altered according to the particular situation.
Like in other programming languages variables are one of the major building
blocks of C++ programming language. The variables set the location into the
memory and give it certain name so you can store certain value and access the
particular location of memory. The name given to the variable is known as
identifier. It is so called because it identifies/indicates certain memory location.
In C++ programming language there are certain rules for identifiers so, being in
the boundary of those you can declare an identifier.

Lab Manual Page 89 of 104


Computer Programming

Some of the rules are given as:

1) The identifier can contain letters form a-z, numbers form 0-9 and an
underscore sign.
2) The identifier can be in upper or lower case but the variable in upper case will
differ from the variable in lower i.e. ANS is not same as ans or Ans.
3) The first character of the identifier must be letter or an underscore sign.
4) The identifier should not contain any space (white space) within it.
5) You can also give underscore sign in the middle of the identifier as an space
for your ease for example, square_inch.
6) The identifier must not be same as the keywords—the words predefined in
C++ which have their own specific meaning and function. Like, main, void,
return, cout, cin etc. are keywords so the identifier should not be like them.
7) The identifier can be as long as you like, but only the first 247 characters (in
Visual C++) or 250 characters (in C++ Builder) will be recognized.
8) The identifier must be unique through out the program i.e. if you have
declared the identifier Var1 so, to access or call it you must give its same
name Var1.

Some valid identifiers are: Var, var, VAR, Var1, VAR1, Var_one, _Var1,
_Var_one_of_one etc.
Some of invalid identifiers are: 1Var, 1_var, void, cout, etc.

Hint: The standard and easy way to declare the identifier is to declare all
characters of its in lower case like, var1, var2 etc.
9.1.12.1 Declaring and Defining a Variable

You might think that the two words declaring and defining are equivalent but in
fact there is a lot of difference between both of them. The declaring is the
process of giving a name to the variable and its data type. The data type means
that which type of value will be stored in that variable whereas the name of the
variable must follow the identifier rules of C++.
int var1;

The above line is an example of declaring a variable in which the variable is


given the name var1 and integer data type declared for it which tells the
computer that the value stored in the variable var1 must be an integer.
Whereas the process of initializing certain value to the variable at the time of
declaration is referred as defining a variable. The line below illustrated the
concept of defining a variable:
int var1=50;

In above line the variable var1 is initialized with the integer value 50.
In defining a variable we set/initialize some values to the variable before the
compiling.

Lab Manual Page 90 of 104


Computer Programming

The above program starts with two preprocessor directives which include two
header files which contain definitions of some functions and keywords as, cout
and getch(). Then in main function one variable mixture is declared and three
variables ethane, methane and propane are defined. The first variable mixture is
only declared as it is only given the name and its data type and no value is set in
the memory location of the variable. Where as in the second variable
initialization statement the memory location is set for the three variables and a
certain value is initialized to the memory location of the variables. The last four
cout statements prints the values of the variable stored in to them on the
console screen with some strings.

9.1.13 Data Types


The variables are the fundamental building blocks of C++ as discussed earlier,
which set the memory location by giving them certain names. The variables can
store certain data/values into those memory locations but the data/values stored
in to the variables are of different types and occupy different sizes of memories.

Lab Manual Page 91 of 104


Computer Programming

9.1.13.1 Integer data type

The numeric data having no fractional/decimal part is known as integer data.


The integer data type variables can only store and represent integer data. The
integer data type is of three types i.e. type int, type short and type long.

Type int occupies 4 bytes (32 bits) of memory. In type int you can store the
integers with in the rage of -2,147,483,648 to 2,147,483,647. To define or
declare a type int variable use the keyword int before the variable name like,
int var1= 1000000000;

Type short occupies 2 bytes (16 bits) of memory. In type short you can store the
integers within the range of -32,768 to 32,767. To define or declare a type short
variable use the keyword short before the variable name like,
short var1=10;

Type long occupies 4 bytes (32 bits) of memory. In type long you can store the
integers with in the rage of -2,147,483,648 to 2,147,483,647. To define or
declare a type long variable use the keyword long before the variable name and
place the letter L after the integer constant like,
long var1=1000000000L;

9.1.13.2 Floating point data type

The numeric data having fractional/decimal part is known as floating point data.
The floating point data can store and represent floating point data. The floating
point data type is of three types i.e. type float, type double and type long
double.

Type float occupies 4 bytes (32 bits) of memory. In type float you can store the
floating point values within the range of 3.8 x 10-38 to 3.8 x 1038 with the
precision of seven (7) digits. To define or declare a type float variable use the
keyword float before the variable name and place the letter F after the floating
point constant like,
float PI=3.1415F; but placing F is optional.

Lab Manual Page 92 of 104


Computer Programming

The other two floating point data types are same as type float but they offer
wider range of values and precisions.
Type double occupies 8 bytes (64 bits) of memory. In type double you can store
the floating point values within the range of 1.7 x 10-308 to 1.7 x 10308 with the
precision of fifteen (15) digits. To define or declare a type double variable use
the keyword double before the variable name like,
double PI=3.141592654;

Type long double occupies 10 bytes (80 bits) of memory. In type long double you
can store the floating point values within the range of 1.2 x 10-4932 to 1.2 x
104932 with the precision of nineteen (19) digits. To define or declare a type
long double variable use the keyword long double before the variable name and
place the letter L after the floating point constant like,
long double PI=3.141592654546845348645454L; but placing L is optional.

In floating point data types you can write the floating point constants using
exponential notation, which is the way to write very large or very small numbers
in the power of ten. Like instead of writing 2,000,000,0 you can write 1.0E7 in
exponential notation. Similarly for 52349.2 you can write 5.2E4 and for
0.0000006024 you can write 6.02E-7. double atoms=6.02E-7;

If you want to define a floating point variable then in type float place a letter F in
the end of the constant number, in type double you don’t have to identify the
complier that it is a constant value it considers it as default but in type long
double you have to place the letter L after the constant number. But placing F
and L is optional.
float PI=3.1415F; double PI=3.141592654;

long double

PI=3.141592654546845348645454L;

You can also make the value of the floating point variable constant through out
the function by using the constant qualifier i.e. const. To define a constant
floating point variable place the keyword const before the data type of the
variable as in:
const float PI=3.1415F; const double

PI=3.141592654; const long double

PI=3.141592654546845348645454L;

Examine the following program:

Lab Manual Page 93 of 104


Computer Programming

This program defines the constant value of the variable PI and declares the
integer variable radius and a type float variable area. The program gets the
value of radius during the run-time in integer type and then puts it in the
expression area=PI*(radius*radius) and calculates the value of area and finally
shows the value of area.

9.1.13.3 Character Data Type

The data containing individual characters is known as character data. The


character data type variables can only store and represent the characters. The
character data type variables can only store single character at a time in a
single variable.
Type char occupies 1byte (eight bits) of the memory. In type char you can store
the characters within the range of integers -128 to 127, whereas the integers -
128 to 127 represent the ASCII equivalents to the characters. To declare a
character data type use keyword char before the variable name as in,
char ch;

The above declaration indicates that the variable ch is a character type data
variable and in the program it will only store the characters. And to define a
variable you can either give the character in single quotation marks or you can
give the ASCII equivalent to that character. For example if we want to store the
character A (capital A letter) in the variable ch then we can write as in,
char ch=’A’;

char ch=65;

In first line the character A is enclosed in single quotation marks so the character
A will be store in the variable ch where as in second line the number 65 is the
ASCII equivalent to the character A so the computer will translate it in to

Lab Manual Page 94 of 104


Computer Programming

character A and will store it in the variable ch. No matter which method you
perform the aim of both the methods is same.
Examine the following program:

Numerical Range Precisio Bytes of


Data Type
Low High n Memory
char -128 127 n/a 1
short -32,768 32,767 n/a 2
int - 2,147,483,64 n/a 4
2,147,483,64 7
8
long - 2,147,483,64 n/a 4
2,147,483,64 7
8
float 3.4 x 10-38 3.4 x 1038 7 4
double 1.7 x 10-308 1.7 x 10308 15 8
long double 1.2 x 10-4932 1.2 x 104932 19 10

9.1.13.4 Unsigned data types

The data types int, short, long and char have their range with in which they can
store certain values and these ranges start from some negative number to
positive number. So by eliminating negative numbers we can extend the size of
the data types. Doing this will make the data types to store large values as twice
as the signed data types do.
The unsigned data types are used when we are dealing with only positive
numbers. To convert a signed data type into an unsigned data type place the
keyword unsigned before the data type as in,
unsigned int var1=12000;

Lab Manual Page 95 of 104


Computer Programming

Type unsigned char occupies 1 byte (8 bits) of memory. In type unsigned char
you can store the characters within the range of integers 0 to 255, whereas the
integers 0 to 255 represent the ASCII equivalents to the characters. To declare
an unsigned data type variable use keywords unsigned char before the variable
name as in,
unsigned char ch=250;

Type unsigned short occupies 2 bytes (16 bits) of memory. In type unsigned
short you can store the integers within the range of 0 to 65,535. To declare an
unsigned short data type variable use the keywords unsigned short before the
variable name as in,
unsigned short var1=50;

Type unsigned int and type unsigned long occupy 4 bytes (32 bits) of memory. In
both the data types you can store the integers within the range of 0 to
4,294,967,295. To declare an unsigned int and unsigned long data type use the
keywords unsigned int and unsigned long respectively before the variable names
as in,
unsigned int var1=10000;

unsigned long var1=10000;

Numerical Range Bytes of


Data Type
Low High Memory
char 0 255 1
short 0 65,535 2
int 0 4,294,967,2 4
95
long 0 4,294,967,2 4
95

9.1.14 The const Qualifier


The keyword const is known as the constant qualifier. It specifies that the value
of the variable will remain constant and will not be altered throughout the
function. If any attempt is made to alter the value of the variable the compiler
will give the error. It is always placed before the data type of the variable as in,
const float PI=3.1415F;

It specifies that the variable PI stores the floating point number 3.1415 and this
value will not be altered and will remain constant.
Examine the following program:

Lab Manual Page 96 of 104


Computer Programming

9.1.15 Assignment Statements


The statements that assign certain values to certain variables are known as
assignment statement. The assignment statements always contain an equal sign
which is actually the assigner of the values to the variables. Like other
statements the assignment statements always terminate with the terminator.
The statements var1=10; var1=var1+15 var1=var2+15;

are the assignments statements which assign the values to the variable var1.
The assignment statements assign the value from the right of the = sign to the
variable on the left. To assign a variable it must be noted that the variable must
be declared before it is assigned.

9.1.16 The endl Manipulator


Manipulators are the instructions to the output stream that modify the output in
various ways. The endl manipulator is also the instruction to the output stream
i.e. cout, which manipulates/modifies the output displayed in the console screen.
The endl manipulator used in output stream cout causes the line feed. Whenever
the endl manipulator comes in cout statement it moves the cursor to the starting
of the next line. It has same effect as \n escape sequence has to cause the line
feed but endl is somewhat clearer and it also causes the output buffer to be
flushed. The endl causes the next string constant in the cout statement to be
printed on the new fresh line.
Examine the following program:

Lab Manual Page 97 of 104


Computer Programming

In the first cout statement the variables a and b are added, in second the
variables are subtracted, in third the variables are multiplied, in fourth the
variables are divided and in fifth the variable are remaindered. The output of this
program is:

9.1.17 Arithmetic Assignment Operators


The operators used in assignment statements to shorten and clarify the code are
known as arithmetic assignment operators. They are +=, -=, *=, /= and %=. In
some situation probably you would have faced some statements like,
a=a+b; b=b-

10;

var1=var1*5

0;

var1=var1/va

r2;

Lab Manual Page 98 of 104


Computer Programming

In these statements a certain value is given to a variable by performing some


arithmetic operation but one variable is used twice in the statements which is
really stretching therefore C++ also offer other approach to shorten and make
the assignment statements more clearer. In this approach you can use the
arithmetic assignment operators +=, -=, *=, /= and %= which have the same
effects as above.
In C++ a=a+1; and a+=1; have the same effects. Some other equivalents are,
electrons += 1; is same as electrons=electrons+1; electrons -= 1;

is same as electrons=electrons-1; electrons *= 1; is same as

electrons=electrons*1; electrons /= 1; is same as

electrons=electrons/1; electrons %= 1; is same as

electrons=electrons%1;

9.1.18 Relational Operators


The relational operators are the operators which compares the operands. There
are only two possible values that the relational operators can give after
performing the operation on the operands i.e. 0 or 1. If the condition becomes
true when the operands are compared with relational operators we get the value
1. On the other hand if the condition becomes false when the operands are
compared with relational operators we get the value 0. There are six relational
operators they are, Greater than >, Less than <, Equal to =, Not equal to !=,
Greater than or equal to >=, Less than or equal to <=.

Lab Manual Page 99 of 104


Computer Programming

Operator Description
> Greater than

< Less than

== Equal to

!= Not equal to

>= Greater than or equal to

<= Less than or equal to

9.1.19 Logical Operators


Logical operators logically combine the Boolean variables (0 and 1). There are
three logical operators And &&, OR || and Not !. They have wide scope when
used with relational operators. They combine the Boolean value obtained by
relational operators. Like in relational operators we can only compare two
operands and get the true or false value of only single comparison but if we want
to make the condition satisfied only when the two or more comparison are
satisfied then we use logical operators.
And && operator combines the Boolean values and makes the condition satisfied
only when all the comparisons are satisfied as,
(a>b && a>c && a>d)

OR || operator combines the Boolean values and makes the condition satisfied
when atleast one comparison becomes true as,
(a>b || a>c || a>d)

Not ! operator combines the Boolean values and makes the condition satisfied
only when all the comparisons become false as,

Lab Manual Page 100 of 104


Computer Programming

(!(a>b)&& !(a>c)&& !(a>d))

Operator Description
&& Logical AND
|| Logical OR
! Logical NOT

9.1.20 Increment Operators


The increment operators in C++ can increment or decrement the value of the
variables by one. The increment operators lie in the category of unary operates.
In C++ unary operators have the higher precedence than the other operators.
To increment the variable by the value of one the operator ++ is used and to
decrement the variable by the value of one the operator -- is used. The
operators ++ and -- can be used in the two ways as a prefix or as a postfix.
When the operator is used in the prefix, the variable follows the operator and
when the operator is used in the postfix the operator follows the variable. Look
at the below codes:
int ans=10; cout<<++ans; //operator used

as prefix int ans=10; cout<<and++;

//operator used as postfix

In first two line codes the value of the variable “ans” is incremented first and
then it is printed on the console screen but in the second two line codes the
value of the variable “ans” is first printed on the console screen and then it is
incremented the one. Operators used as prefix and as postfix behave differently.
In C++,
Word=Word+1 is same as Word += 1 is same as ++Word Word=Word-1

is same as Word -= 1 is same as --Word

Lab Manual Page 101 of 104


Computer Programming

9.2 PROCEDURE
9.2.1 Problem example
Consider the following problem example. We are going to write C++ source code
in Code::Blocks IDE.

Problem statement: Write a program in C++ that accepts the width and the
height of a rectangle from the user and prints the area of the rectangle.

9.2.2 Source Code in Code::Blocks


Step 01: Run Code::Blocks IDE.
Step 02: Create new cpp file by going in to File Menu>New>File.
Step 03: Select C/C++ Source from template dialog box.

Step 04: Press Go button and then press Next button.


Step 05: Select C++ and press Next.

Lab Manual Page 102 of 104


Computer Programming

Step 06: Press button and create a new file with .cpp extension by choosing
the destination location of the file.

Step 07: Click Finish button.

Lab Manual Page 103 of 104


Computer Programming

Step 08: Write your code in Code Window.

Step 0 9 : Click button to compile the code.

Step 10: Debug any error in the code and recompile it.

Step 11: Click button to run the code.

Lab Manual Page 104 of 104


Computer Programming

EXERCISE
1. Write a single C++ statement to accomplish each of the following
(assume that using directives have not been used):

a. Declare the variables c, thisIsAVariable, q76354 and number to be of type int.


b. Prompt the user to enter an integer. End your prompting message with a
colon (: ) followed by a space and leave the cursor positioned after the space.
c. Read an integer from the user at the keyboard and store it in integer variable
age.
d. Print the message "This is a C++ program" on one line.
e. Print the message "This is a C++ program" on two lines. End the first line
with C++.
f. Print the message "This is a C++ program" with each word on a separate
line.
g. Print the message "This is a C++ program". Separate each word from the
next by a tab.

2. Write a statement (or comment) to accomplish each of the following


(assume that using directives have been used for cin, cout and
endl ):

a. State that a program calculates the product of three integers.


b. Declare the variables x, y, z and result to be of type int (in separate
statements).
c. Prompt the user to enter three integers.
d. Read three integers from the keyboard and store them in the variables x, y
and z.
e. Compute the product of the three integers contained in variables x, y and z,
and assign the result to the variable result.
f. Print "The product is " followed by the value of the variable result.
g. Return a value from main indicating that the program terminated
successfully.

3. Using the statements you wrote in Exercise 2, write a complete


program that calculates and displays the product of three integers.
Add comments to the code where appropriate. [Note: You’ll need to
write the necessary using directives.]

4. What, if anything, prints when each of the following C++ statements


is performed? If nothing prints, then answer “nothing.” Assume x =
2 and y = 3.

a. cout << x;
b. cout << x + x;

Lab Manual Page 105 of 104


Computer Programming

c. cout << "x=";


d. cout << "x = " << x;
e. cout << x + y << " = " << y + x;
f. z = x + y;
g. cin >> x >> y;
h. // cout << "x + y = " << x + y;
i. cout << "\n";

5. Write a program that asks the user to enter two numbers, obtains
the two numbers from the user and prints the sum, product,
difference, and quotient of the two numbers.

6. Write a program that prints the numbers 1 to 4 on the same line


with each pair of adjacent numbers separated by one space. Do this
several ways:

a. Using one statement with one stream insertion operator.


b. Using one statement with four stream insertion operators.
c. Using four statements.

7. Write a program that reads in the radius of a circle as an integer and


prints the circle’s diameter, circumference and area. Use the
constant value 3.14159 for π. Do all calculations in output
statements.

8. Write a program that prints a box, an oval, an arrow and a diamond


as follows:

9. The formulas for calculating Body Mass Index (BMI) are

Lab Manual Page 106 of 104


Computer Programming

Create a BMI calculator application in C++ that reads the user’s weight in
pounds and height in inches (or, if you prefer, the user’s weight in kilograms
and height in meters), then calculates and displays the user’s body mass
index.

Lab Manual Page 107 of 104

You might also like