Vous êtes sur la page 1sur 176

1

Introduction to Computing
CSL-111

LAB JOURNAL
Name: __________________________________________

Enrollment No: __________________________________

Section: _________________________________________

2
DEPARTMENT OF ELECTRICAL ENGINEERING

BAHRIA UNIVERSITY ISLAMABAD CAMPUS

Exp. Obtained
Experiment Name Date Sign
No Marks
1 Building up the Computer System

2 Basics of Microsoft DOS

3 Fundamentals of Web Development

4 Basics of Microsoft WORD

5 References and Mailing Tab of MS Word

6 Fundamentals of MS Power Point

7 Introduction to MS Excel

8 Fundamentals of Pseudocodes

9 Algorithm development through Visual Logic

10 Introduction to Visual Studio and Code Debugging

11 Programming basics (operators, console input/output,


logic development)

12 Decision structures (if, if-else)

13 Decision structures (Nested if, Nested if-else, switch


statements)

14 Basics of MATLAB

3
Total Marks: _______________ Signature: _________________

4
EXPERIMENT 01

Building up the Computer System


Objectives
1) To become familiar with the Windows OS environment
2) To become familiar with the hardware of your computer

Equipment /tool Used


 Computer with any version of windows installed

Background
What is a Computer?
• [Norton] A Computer is an electronic device that processes data, converting it into
information that is useful to people
• [Wikipedia] A Computer is a programmable device, usually electronic in nature, that can
store, retrieve and process data
• [The American Heritage Dictionary]
1. A device that computes… especially a programmable electronic machine
that performs high-speed mathematical or logical operations or that
assembles, stores, correlates, or otherwise processes information
2. One who computes

A computer does what it is told to do…


You tell a computer what to do by giving it a list of precise, unambiguous instructions, a
computer program
Windows is the most common operating system used for PCs. It is essential that you familiarize
yourself with the basic functionality of this OS.

It is necessary that you are aware of the hardware in your computer. While the operating system
usually takes care of the complexity of managing the hardware of your computer system,
knowing the hardware helps when you have to:

1) Install an operating system

5
2) Upgrade your computer system
3) Diagnose and repair problems in your computer system

Tasks:

1) Familiarize yourself with the following basic tasks specific to Windows operating systems
[ask your instructor if you have problems]:

a) Copying/ pasting a file [select a file, right click> copy; go to the directory to paste into, right
click > paste]
Solution

b) Creating a new file [hint: right click > new > file type]
Solution

c) Creating a new folder [hint: right click > new > folder]

6
Solution

d) Deleting a file [hint: select a file, right click > delete]


Solution

e) Finding how to find Windows help [hint: click on Windows Start button, and then on Help
and Support, explore what kind of help is available]
Solution

7
2) To check the hardware present in your computer, Right click on My Computer and then click
on Properties note down the specifications of the PC you are working on the default tab.

Figure: 1.1 All Control Panel Items

Solution

8
a. What is the Operating System being used? (write complete details)

Solution

b. What is the CPU name?

Solution

c. What is the clock speed of the computer’s CPU?


Solution

9
d. What is the amount of RAM present?

Solution

3) Click on the Remote settings then Computer Name tab.

Figure: 1.2 System Properties

Solution

10
a. What is the computer’s description?
Solution

b. What is the computer’s full name?


Solution

c. What is the name of computer’s workgroup?

(A workgroup is Microsoft's terminology for a peer-to-peer PC computer network.


Machines (with Microsoft operating systems) in the same workgroup may allow each
other access to their files, printers, or Internet connection. Members of different
workgroups on the same local area network segment and TCP/IP network can only
access resources in workgroups to which they are joined.
[http://en.wikipedia.org/wiki/Workgroup_(Computer_networking)])
Solution

4) Click on the Hardware tab and then on Device Manager, note all information about hardware
devices here and answer the following questions?

11
Figure: 1.3 Device Manager

(Hint: you can right-click on any device and see further properties)

Solution

a) What is the name of the disk drive?


Solution

b) Does the computer have a Bluetooth radio?


Solution

12
c) Does the computer have a network adapter?
Solution

d) What is the name of the monitor? Is the proper driver of the monitor installed? What is the
name of the provider of the driver for the monitor?
Solution

e) Find out the name of your hard disk?


Solution

5) Practice some keyboard shortcuts

 F1: Help

 CTRL+ESC: Open Start menus

 ALT+TAB: Switch between open programs

 ALT+F4: Quit program

 SHIFT+DELETE: Delete item permanently

 Windows Logo+L: Lock the computer (without using CTRL+ALT+DELETE)

 CTRL+SHIFT+ESC: Opens Windows Task Manager

 SHIFT+DELETE: Deletes an item immediately without placing it in the Recycle Bin

 Windows Logo: Start menu

13
 Windows Logo+R: Run dialog box

 Windows Logo+M: Minimize all opened windows

 Windows Logo+F1: Help

 Windows Logo+E: Windows Explorer

 Windows Logo+F: Find files or folders

 Windows Logo+D: Minimizes all open windows and displays the desktop

 Windows Logo+TAB: Cycle through taskbar buttons

 TAB: Move to the next control in the dialog box

 F6: Move the cursor to address bar in internet explorer


6) What are the key board shortcuts for the following actions?
a) Open run dialog box
Solution

b) Open windows explorer


Solution

c) Close the current window


Solution

d) Open search
Solution

e) Minimize all windows


Solution

14
f) Move the cursor to address bar in internet explorer
Solution

g) Cycle through the taskbar buttons


Solution

h) Opens Windows Task Manager


Solution

i) Lock the computer


Solution

j) Delete an item without placing it in the recycle bin.


Solution

Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

15
Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

16
Trouble Shooting Can clearly Sufficiently Describe the Cannot describe
identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: _______________

EXPERIMENT 02

Basics of Microsoft DOS

Objectives

To develop understanding of Operating system basics command line interface through MS DOS.

Equipment /tool Used


 Computer with any version of windows installed

Background

MS.DOS is an abbreviation for MICROSOFT DISK OPERATING SYSTEM, it is basically a


non-graphical command line operating system derived from 86-DOS MS-DOS enables a user to
navigate and perform several operations on their systems from a command line instead of a
window.

MS DOS Basic Commands

17
The Command Prompt

 C:/>

This is called the command prompt, the flashing underscore next to the command prompt
is called cursor. The cursor shows where the command you type will appear.

 Nul

1- If you make a typing mistake, press the BACKSPACE key to erase the mistake, and then
try again.
2- Press ENTER.

1- Viewing the Contents of a Directory


Type the following at the command prompt:
Dir

a) View the contents of a directory


Solution

2- Changing Directories

18
Type the following at the command prompt:
cd windows
The command prompt changes. It should now look like the following:
C:\WINDOWS>
b) Change from one directory to another.
Solution

3- To view a list of the files in the WINDOWS directory


Type the following at the command prompt:
dir

To view contents of a directory on screen at a time


1. Type the following at the command prompt:

dir /p
When you used the /p switch with the dir command, you specified that MS-DOS should pause
after it displays each screen of directory list information. The p stands for "page".

To view the contents of a directory in wide format


1. Type the following at the command prompt:

dir /w

If the directory contains more files than will fit on one screen, you can combine the /p and /w
switches as follows:

19
dir /w /p.

4- Changing Back to the Root Directory


Type the following at the command prompt:
cd \
The command prompt should now look like the following:
C:\>
c) Change to root directory.
Solution

5- Creating a Directory
In this section, you will create two directories. Creating a directory is helpful if you want
to organize related files into groups to make them easy to find. Before you begin this
section, make sure the command prompt looks like the following:
C:\>
To create a directory, you will use the md command. The md command stands for "make
dir
To create and change to a directory named FRUIT
1. Type the following at the command prompt:
2. md fruit
3. Dir
To change to the new FRUIT directory, type the following at the command prompt:
cd fruit
The command prompt should now look like the following:
C:\FRUIT>
You will now create a directory within the FRUIT directory, named GRAPES.
To create and work with a directory named GRAPES
1. Type the following at the command prompt:
md grapes
Confirm that you successfully created the GRAPES directory?
To change to the GRAPES directory, type the following at the command prompt:
cd grapes

20
The command prompt should now look like the following:
C:\FRUIT\GRAPES>
1. To switch back to the FRUIT directory, type the following:
cd..
d) Create directories.
Solution

6- Deleting a Directory
In this section, you will delete the GRAPES directory. Before you begin this section, make sure
the command prompt looks like the following:
C:\FRUIT>
To delete a directory, use the rd command. The rd command stands for "remove directory."

To delete the GRAPES directory


1. Type the following at the command prompt:
rd grapes
Before you begin this section, make sure your command prompt looks like the following:

e) Delete directories.

21
Solution

7- Changing Directory
C:\FRUIT>
Type the following at the command prompt:
d:
f) Change from one drive to another.
Solution

8- Copying Files
Before you begin this section, make sure the command prompt looks like the following:
C:\FRUIT>
To copy the NOTEPAD.EXE files from the WINDOWS directory to the FRUIT directory
1. Return to the root directory by typing the following at the command prompt:
cd\
The command prompt should now look like the following:
C:\>
2. Change to the DOS directory by typing the following at the command prompt:
cd windows
The command prompt should now look like the following:
C:\WINDOWS>
3. To copy the NOTEPAD.EXE file from the WINDOWS directory to the FRUIT
directory, type the following at the command prompt:
copy c:\windows\notepad.exe c:\fruit

The following message appears:


1 file(s) copied

22
4. To confirm that you copied the files successfully, view the contents of the FRUIT directory by
typing the following at the command prompt:
dir \fruit
g) Copying files.
Solution

9- Rename a file
To rename a file, you will use the ren command. The ren command stands for "rename."
When you use the ren command, you must include two parameters.
ren old name new name
Before you begin this section, make sure your command prompt looks like the following:
C:\FRUIT>
1. To rename the NOTEPAD.EXE file to PADNOTE.TXT, type the following at the
command prompt:
ren notepad.exe padnote.txt
h) Rename the file.
Solution

10- Deleting Files


Before you begin, make sure your command prompt looks like the following:
C:\FRUIT>

23
1. Delete the PADNOTE.TXT file by typing the following at the command prompt:
del PADNOTE.TXT
To delete the FRUIT directory
2. Return to the root directory by typing the following at the command prompt:
cd \
3. You can see the FRUIT directory in the directory list by typing the following at the
command prompt:
dir or dir /p
4. Remove the FRUIT directory by typing the following at the command prompt:
rd fruit.
i) Deleting the file.
Solution

Tasks:
How are the following operations done in MS DOS?
1) Show the version of windows.
Solution

2) Show help
Solution

24
3) Show time
Solution

4) Show volume
Solution

5) What does Exit command do?


Solution

6) Use help command to explore the following.


a. Tree
Solution

b. Pause
Solution

d. cls
Solution

25
Home task

How are the following operations done in MS-DOS? Give the syntax and explain the command
(all answers must be typed along with the questions to be in BOLD)

1. Net
Solution

2. Ping
Solution

3. Set
Solution

4. Assign
Solution

26
5. Attrib
Solution

Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

Lab Assessment Rubric

27
Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)
improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 03

28
Introduction to Web Development

Objectives

To develop a basic web site.

Equipment /tool Used


 Computer with any version of windows installed

Background

Internet is a ‘Network of Networks’.


On the Internet, a website is represented by a URL (uniform resource locator). World Wide Web
(WWW), also abbreviated as the web, is a system of interlinked hypertext documents that may
be viewed through a web browser. Web can be accessed through web browsers like Internet
Explorer, Google Chrome and Mozilla Firefox etc. To understand how WWW works, it’s
important to first define what hypertext documents are.

Hypertext:

“Hypertext most often refers to text on a computer that will lead the user to other, related
information on demand. Hypertext allows a form of user interface, which overcomes some of the
limitations of written text. Rather than remaining static like traditional text, hypertext makes
possible a dynamic organization of information through links and connections (called
hyperlinks). Hypertext can be designed to perform various tasks; for instance, when a user
"clicks" on it or "hovers" over it, a bubble with a word definition may appear, a web page on a
related subject may load, a video clip may run, or an application may open.” [Wikipedia]
HTML:

HTML is a hypertext markup language that is used to describe the structure of a webpage using
tags. A web browser, an application that understands HTML tags and displays web pages
accordingly, utilizes the HTTP protocol to receive HTML pages from a web server (also called
HTTP server).
It is important to note that the display of an HTML page in a browser is not the same text that we
see if we were to edit the HTML page in a text editor. This is because the HTML file itself
contains many instructions/ tags that are not displayed in the browser. The function of these tags/
information is simply to enable a browser to display the HTML file. This should become clear as
we go through the exercises.

Let’s develop a basic website

Part I---Creating directory/ index.html and format.css files

29
 In this part, we will create a directory in which we will save today’s lab work. We will
also learn how to create and save index.html and format.css files.
 On the desktop, create a folder named ITCLab3
[Hint: this can be done by right clicking on the desktop, and then choosing New and then
Folder]
 Create an index.html.
 Open the Notepad application. [Start > Programs > Accessories > Notepad]
 Save the empty file as index.html by clicking on the File menu of the Notepad.

On the file menu, choose “Save As”. The “Save As” window will appear as shown below:

In a similar manner, create the format.css file. [We will later see how this file is used]

Figure: 3.1 Save As

30
Save the empty file as index.html on the Desktop. [We will use the Desktop as HTML
playground, and once the files have been finalized, then they will be transferred to the ITCLab2
folder.] To save the file as index.html, index.html must be written as the file name with the “Save
as type” set to All Files.
• Note: As explained the “Save as type” should be set to All Files, if the “Save as type”
field is set to Text Documents (*.txt) then the file would be saved as index.html.txt
and not as index.html.

Figure: 3.2 Save As-All Files

Part II--- HTML Basics

1. Writing the HTML basic tags


Open the index.html file on the Desktop and enter the <html> and </html> tags on the file.
Note that in HTML, tags often (but not always) follow the convention that there is an
opening tag and a closing tag. The opening tag in our context is <html> and the closing tag is
</html>. These tags are used to inform the browser that the text between these tags is
formatted according to HTML guidelines. The <html> tags are displayed in the figure below.

Figure: 3.3 Index.html

• In the figure above, we do not have any HTML code in between the <html> tags. We
will now start to code the HTML page.

2. Inserting the title of the web page


We will, first of all, learn the <head> tag and the <title> tag.
• The head element (text between the head tags) contains general information, also
called metainformation, about a document. The title (text between the title tags) is not
part of the text of the document but is a property of the whole document. It may not
contain anchors, paragraph marks, or highlighting. The title may be used to identify
the node in a history list, to label the window displaying the node, etc.

31
• We will name the title of our webpage as ITC lab 03. Note how the title text is
enclosed in the head tags and the title tags.

Figure: 3.4 Head and Title Tag

Open the index.html file on the Desktop (modified as above) with Internet Explorer (this can be
done by simply double clicking on the index.html file). You will find that the Internet Explorer
displays “ITC Lab 03” as the title of the web page as configured in the figure above. The
webpage is still empty as we have not added any text in the main page’s body yet (we will do
that soon).
For now, the index.html page should look like the following.

Figure: 3.5 Head and Title Tag Display

• Copy the index.html into the ITCLab3 folder on Desktop and rename it as Title.html.
[Hint: a file can be renamed by selecting, right clicking, and choosing the rename
option.]

3. Inserting text in a HTML page


• We will now add text to the main body of the HTML page. This is done using the
<body> and </body> tags. The text contained between the <body> and </body> tags
is displayed by a browser unlike data that is contained between the <head></head>
tags.
• Add the text contained in the following figure in the index.html file on the Desktop.
Save the file when done. The index.html file on Desktop should like the following.

32
Figure: 3.6 Inserting Text
• After saving the index.html file on Desktop, open the file in a browser (by double
clicking on the file). If the index.html file is properly configured, the browser display
should be as follows. You will notice that all there is no line break, and all the text we
had put between the <body> tags is on one line.
• A browser has to be told by HTML tags where line breaks, new paragraphs, etc.
should occur. Since we have not used those tags yet, all the text is on one line as
shown in the figure below.
• Save the index.html file on the Desktop in the ITCLab3 folder as Allon1line.html.

Figure: 3.7 Inserting Text Display


4. Inserting a line-break
• We will now use the <br> HTML tag to introduce line breaks. This tag does not have
a corresponding close tag and is used for introducing line breaks.
• Open the index.html file on the Desktop and make the changes highlighted in the
following figure.

33
Figure: 3.8 Inserting Line Break

• After making the changes, save the index.html file and open it using a browser. The
browser should display the page with proper line breaks as shown in the figure below.
You will see that all the text is not on the same line any more.

Figure: 3.9 Inserting Line Break Display

• If you see the browser display as above, save the index.html file on the Desktop to the
folder ITCLab3 as Linebreak.html.

5. Insert a paragraph

• In the figure above, all the text is in a single paragraph (although separated by line
breaks). To start a new paragraph, the HTML tag <p> should be used. The tag <p> is
used to mark the start of a paragraph, and the end of paragraph is marked by </p>.
• To observe how a paragraph is formatted in HTML, open the index.html file on the
Desktop. Make the changes highlighted in the following figure and then save the file.

34
Figure: 3.10 Inserting Paragraph

• Open the index.html file on the Desktop (modified with the changes highlighted
above) with a browser. You will see now that the web page is composed of two
paragraphs. The second paragraph also has line breaks within the paragraph. The
browser display should look like the following.

Figure: 3.11 Inserting Paragraph Display

• If you see the browser display as above, save the index.html page on the Desktop to
the ITCLab3 folder and name it as Paragraph.html.

6. Inserting headings

35
In the index.html file on the Desktop, currently no text is highlighted as a heading. If certain
text is to be a heading, the HTML tags <h1></h1>, <h2></h2>, <h3></h3>, <h4></h4>
(and so on) may be used. The tag <h1> is used for bigger sized heading with the heading size
decreasing for <h2> <h3> and so on.

Open the index.html file on the Desktop and make the changes highlighted in the following
figure. The first paragraph is highlighted using the <h1> tags.

Figure: 3.12 Inserting Headings

• After making the changes in the index.html file on the Desktop as shown above, save
the file. Open the file now with a browser. The browser display should look like the
following. You will note that the first paragraph now highlighted as a heading with a
large sized font.

36
Figure: 3.13 Inserting Headings Display

7. Inserting a hyperlink

We will now add a hyperlink on the index.html file. Open the index.html file on the Desktop and
make the change highlighted in the following figure.

Figure: 3.14 Inserting Hyperlink

• Save the file after making the change highlighted above. Open the file using a
browser. You should see that the browser display is similar to as shown below. You
will observe that a hyperlink to the specified URL is now added. Click on the URL
and note where the target of the hyperlink.
• If the browser display is similar to as shown above, save the index.html file on the
Desktop to the folder ITCLab3 as Hyperlink.html.

37
Figure: 3.15 Inserting Hyperlink Display

Figure: 3.16 Links added

Figure: 3.17 Links added

8. Making text italic, underlined, or bold

We will now see how a text can be italicized, underlined, or made bold in HTML. The tags for
these tasks are, respectively, <i></i>, <u></u> and <b></b>.

38
• Italicizing: To italicize a body of text, it must be enclosed in <i> </i> tags. To
demonstrate this, open the index.html file on the Desktop and make the changes
highlighted in the following figure.

Figure: 3.18 Inserting text italic, underline or bold

• After making the changes shown above, save the file and then open in using a
browser. You will observe that the text between the <i> and </i> tags is italicized. If
the browser display is as shown below, save the index.html file in the ITClab2 folder
as ItalicsAndUnderline.html.

39
Figure: 3.19 Inserting text italic, underline or bold Display

9. Inserting a table and an image


To create a table, add <table> </table> tags.
Add <tbody> </tbody> tags to create body of a table.
To insert columns, add <td> </td> tags.
To insert rows, add <tr> </tr> tags.
To insert an image in an HTML page, <img> tag is used.
We will now demonstrate how an image is added to an HTML page. Modify the index.html
page on the Desktop to as shown below and save the file.

• The HTML page will include the file taimur.jpg as an image. For this to work,
taimur.jpg should be in the same folder as the index.html file. Download the
taimur.jpg file from the course website and place on the Desktop. With the image file
also on the Desktop, open

40
Figure: 3.20 Inserting table and image

• The index.html file using a browser. You should be able to see the image as part of the
web page displayed in the browser

Figure: 3.21 Inserting table and image Display

Tasks
1. Create and save an html file

41
Solution

2. Add html tags in a newly created html file

Solution

3. Add title to the web page

Solution

42
4. Insert some text onto the webpage

Solution

43
5. Format the text through line breaks

Solution

6. Insert a paragraph

Solution

44
7. Insert headings -> h1, h2, h3 etc.

Solution

8. Insert hyperlinks

45
Solution

46
9. Italic, bold and underline the text in paragraphs

Solution

10.Add images and tables in the html webpage

Solution

47
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)

48
improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: _____________

EXPERIMENT 04

Basics of Microsoft Office Word

49
Objectives

To become familiar with word processing and enable students to use the various tools in MS
Word effectively to perform common word processing tasks quickly.

Equipment /tool Used


 Computer with any version of windows installed
 MS Office (MS Word)

Background

Explore Window

Following is the basic window which you get when you start word application. Let us understand
various important parts of this window.

Figure: 4.1 Overview MS WORD

Backstage View

50
The Backstage view has been introduced in Word 2010 and acts as the central place for
managing your documents. The backstage view helps in creating new documents, saving and
opening documents, printing and sharing documents, and so on.

Figure: 4.2 Backstage View

Review Tab

The easiest way to correct spelling mistakes is to right click any word that has a red wavy
underline

Figure: 4.3 Review Tab

To check more than one word at a time, you can bring up the Spelling and Grammar dialogue
box. To see it, click on the Review tab at the top of Word. On the Review tab, locate the
Proofing section. Then click Spelling & Grammar:

51
Figure: 4.4 Spelling and Grammar

Word count provides the statistics that how many pages, lines and paragraphs etc. are in our
document

Figure: 4.5 Word Count

Another way To know the current word count of a document, open the document and right click
on the status bar at the bottom of the Word window. The context menu which comes up will
have an entry named “Word Count” which will tell you the current word count.

52
Figure: 4.6 Alternate for Word Count

Using “Language” tab one can change the language.

To insert a comment first select the text then go to “New Comment” on “Comments” group in
“Review” tab. Click on “New Comment” and a new comment will be inserted. You can also
move to next or previous comments and can also delete the comments using this “comments”
group.

To insert a comment in a document, highlight the area of text where you want to comment on.
Click the Review tab on the Ribbon then click New Comment

Figure: 4.7 Comment

53
Tracking Group:

With this feature of tracking, you can track and view all changes that are made to the document.
1. While in the document, On the Review tab, under the Tracking group, click Track
Changes.

Figure: 4.8 Track changes

1. On the Review tab, in the Changes section, click the Next button to move to the next change.
2. Click the Accept or Reject button to accept the change or reject the change and move to the
next change.
3. Keep going until you’ve responded to all the changes.

In “Compare” group there is an option to compare two different documents. This option is
usually used to find out the similarity between two different documents

Figure: 4.9 Compare Documents

54
After browsing the paths for original and revised documents click” ok”. A new document will be
opened that will highlight the changes present in the both documents.

View Tab

View tab is used to change the document views. Go through each view and observe the changes
that each view brings.

Quick Access Toolbar:

With MS Word 2010 there is also Quick Access Toolbar which has a save, undo Repeat Typing
button and Customize Quick Access drop down list. Within the list there are New, Open, Save,
E-mail, Quick Print, Print Preview and Print, Spelling & Grammar, Undo, and Redo, Draw
Table, Open Recent File icons. You can also choose to show the Quick Access Toolbar below the
Ribbon by choosing Show below the Ribbon selection and you can also customize further with
the More Commands button and make Microsoft Word 2010 suitable to your preferences and
needs. In such a manner Quick Access Toolbar of MS Word lets you performance routine tasks
much faster. The Microsoft Word 2010 Quick Access toolbar and its functionality are shown
below

Figure: 4.10 View Tab

Tasks:
Formatting Text
A computer is a device that accepts information (in the form of digitalized data) and manipulates
it for some result based on a program or sequence of instructions on how the data is to be
processed. Complex computers also include the means for storing data (including the program,
which is also a form of data) for some necessary duration. A program may be invariable and built
into the computer (and called logic circuitry as it is on microprocessors) or different programs
may be provided to the computer (loaded into its storage and then started by an administrator or
user). Today's computers have both kinds of programming.

55
1) Copy the above text and paste in y0ur document.
Solution

2) Copy the last sentence today’s computers have both kinds of programming to the
beginning of the first paragraph.
Solution

3) Change the typeface of the entire document to 11-point Verdana.


Solution

4) Change all the word occurrences of computer to workstation.


Solution

56
5) Change the spacing of the entire document from single spacing to 1.5.
Solution

6) Change the alignment of the entire document to Justify.


Solution

57
7) Set the phrases logic circuitry and microprocessors in Italic.
Solution

8) Change text Case


Solution

9) Change the color of the text.


Solution

58
10) Change the text in form of bullets.
Solution

11) Insert borders and Shades


Solution

12) Insert Text Box


Solution

59
13) Insert Page Numbers
Solution

14) Insert Page Break and Cover Page


Solution

Conclusion:

______________________________________________________________________________

______________________________________________________________________________

60
______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2

61
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 05

References and Mailing tabs of MS Office Word

Objectives

62
To become familiar with word processing and enable students to use the various tools in MS
Word effectively to perform common word processing tasks quickly.

Equipment /tool Used


 Computer with any version of windows installed
 MS Office (MS Word)

Background
Reference Tab

This tab provides the quick way to create table of contents, update it, enter citations or
references, choose any writing styles and footnotes etc. For generating the table of contents first
selects the text from the document to appear in it. After selecting the text, make it a heading from
“Styles” group in home tab. After making different headings, go to “Table of Contents” option in
“Table of Contents” group of “Reference” tab and select any one format.

Figure: 5.1 Table of Contents

In “Footnotes” group there is an option to add footnotes and endnotes. Footnotes and endnotes
are an easy way to add or provide the reader with supplementary information and that
information will appear at the end of the page.

To insert a footnote or endnote, navigate to Footnotes section. To insert a footnote, click the
menu option with text as AB1Insert (Placeholder1) Footnote

63
Figure: 5.2 Footnotes

Similarly, to insert an endnote, click the Insert Endnote menu option.

Figure: 5.3 Endnotes

The keyboard shortcuts for inserting a Footnote are Alt + Ctrl + F for inserting an Endnote is
Alt + Ctrl + D
Similarly, citations and bibliography can be inserted from “Citations and Bibliography” group.
The writing styles can also be changes from here as citations depend upon it. In technical writing
we have many different styles of writing that can be select from this group of “Reference” tab.

Figure: 5.4 Create Source

In “Captions” group, one can give captions to the figures and hence can create the table of
figures in the same manner as table of content were created.

64
Figure: 5.5 Table of Figures

Mailing Tab

We can create, and print envelops and labels using this tab. “Start mail merge” are used to create
a form letter which one uses for printing and sending purpose. We can select the recipient also.

Figure: 5.6 Mailing Tab

Insert Tab
Click the Insert tab and click Table button. This will display a simple grid shown below. When
you move your mouse over the grid cells, it makes a table in the table which appears in the
document. You can make your table having desired number of rows and columns

65
Figure: 5.7 Insert Tab

Click the square representing the lower-right corner of your table, which will create actual table
in your document and word goes in table design mode giving lots of options to work with table
as shown below.

Figure: 5.8 Designs

Following are the simple steps to “delete” an existing table from a word document.

66
Figure: 5.9 Layout

Step (1): Click anywhere in the table you want to delete.


Step (2): Click the Layout tab and click Delete Table option under the Delete Table Button to
delete complete table from the document along with its content.
Following are the simple steps to “add formula” in a table cell available in word document.
Step (1): Consider the following table where we will have total of the rows. Click in a cell that
should contain the sum of rows.

67
Figure: 5.10 Formula Button

Following are the simple steps to “add an existing picture” in your word document. It is
assumed that you already have a picture available on your PC before you add this picture in your
word document.
Step (1): Click in your document where you want to add a picture.
Step (2): Click the Insert tab and then click Picture option available in illustrations group,
which will display Insert Picture dialog box.

68
Figure: 5.11 Insert Picture Dialogue Box

Similarly, you can insert Clip Art, Shapes, and Charts etc.

Task

1. Create the following structure in MS Word

Solution

69
2. Write your name and registration number and insert footnote that shows your academic
qualification.
Solution

3. Write on any topic of your choice and insert a comment (not more than three lines).
Solution

70
4) Using the data given in task 1 use mailing tab to mail the training date to the given
people.
Solution

71
4. Insert table of contents that provides the reference to different tasks.
Solution

72
5. Show “X Y Scatter plot”
Solution

6. Show the following mathematical expression using word equations:

a. Exponential
Solution

73
b. Matrix
Solution

c. Binomial formula
Solution

d. Quadratic formula
Solution

e. Integral
Solution

74
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

_____________________________________________________________________________

Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of

75
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 06

Fundamentals of MS Office PowerPoint

Objectives

 To become familiar with the basics of making presentations using MS PowerPoint


 To become familiar with the basics of good presentation design

Equipment /tool Used


 Computer with any version of windows installed
 MS Office (MS Power Point)

Background
Microsoft Power Point

Microsoft PowerPoint is a software product used to perform computer-based presentations.


There are various circumstances in which a presentation is made: teaching a class, introducing a
product to sell, explaining an organizational structure, etc.

Home Tab

To begin Microsoft PowerPoint, go to Start Menu > All Programs > Microsoft Office >
Microsoft PowerPoint 2010. Select PowerPoint Presentation from the Project Gallery if a blank
document does not open.

The Design Ribbon toolbar contains several categories for formatting the design and elements of
your presentation. These include: Home, Insert, Design, Transitions, Animations, Slide Show,
Review and View. The brief introduction of these tabs is;

 The Home bar: This has features that allow you to edit Slides, Fonts, Paragraph, Drawing
and Editing.

76
 The Insert bar: This has features that allow you to add Tables, Images, Illustrations,
Links, WordArt, and Media Clips.
 The Design bar: This allows you to edit how your presentation will look. It includes
features such as Page Setup, Themes, and Background Styles.
 The Transitions bar: This allows you to edit Slide Transitions, Effects, and Transition
Timing. The Animations bar: This allows you to add custom animations to your
presentation. You can select from Preview, Animations, Advance Animation, and
Animation timing.
 The Slide Show bar: This has features that allow you to select how your presentation will
be displayed. From here, you can start your Slide Show, Set Up your Slide Show, and
Adjust Monitor Settings.
 The Review bar: This allows you to Proofread, Translate Languages, Comment Slides,
and Compare your Presentation.
 The View bar: This has features that allow you to set the View of your Presentation,
Create Master Views, Show/Hide Features, Zoom, Switch from Color to Grayscale,
Adjust Windows, and Add Macros.

Creating a new slide

1. To create a new slide where you can add content, click the Home tab and select New Slide.
2. Clicking the bottom half of New Slide will give you different new slide options.

Figure: 6.1 New Slide

Slide types or layouts include -


 title slides

77
 title and content slides
 comparison slides
 two content
 picture with caption slides
 and more

These layouts of slides will define the appearance of the slide and the way one can put data into
the slides. The layout of the slides can also be change after they are inserted. In Slides group,
there is a drop-down menu named as “Layout”. By clicking on layout tab and selecting a layout
style, the style of current slide can be changed.

Figure: 6.2 Layout

In this tab there is option to cut copy and paste the text. These options are available in
“clipboard” group of Home Tab. Shortcut keys for copy, cut and paste commands are Ctrl+c,
Ctrl+x and Ctrl+v respectively.
Font group allows you to change the font of the text, size, and case etc. of the text. Select the text
first then perform any operation.

Figure: 6.3 Fonts

In order to change the case of text, select the text you want to change then go to Font group of
Home Tab and choose an option from drop down list.
The simplest way to change the way your text looks is to use Bold, Italics, Underline
button on the formatting tool bar. To apply these, just click the button you want your text to be
formatted into. Formatting text involves Underline, Bold, Italic, and Text in different Fonts, Text
in different font sizes, and text in different colors.

Similarly, you can change the text color, outline and appearance etc.

78
You can make the lists by using bullets, numbering and multilevel list in the “Paragraph Group”.
1. Select the paragraphs you want to format
2. Click the Home tab on the Ribbon and click the Bullets or Numbering button in the
paragraph group

Click the list arrow on each button to apply a different style of bullets or numbering

Figure: 6.4 Bullets

Multileveled lists apply different bullets or numbering to the different levels of a list.
1. Select the paragraphs you want to format
2. Click the Home tab on the Ribbon and click the list arrow on the Multilevel List button in the
paragraph group

79
Figure: 6.5 Styles of Bullets

1. Select the style you want to use


2. Change the level of the items in the list by using the Tab key to increase the indent, and by
pressing Shift + Tab keys to decrease the indent
Similarly, text indentation is also done using this “Paragraph” group.

Figure: 6.6 Paragraph

Line and Paragraph Spacing

1. On the home tab of the ribbon, look for the paragraph group. Then click on the Line Spacing
button, as shown in the image below.

Figure: 6.7 Line and Paragraph Spacing

Select your desired line spacing. From this menu you can select to have your line spacing set to
1, 1.15, 1.5, 2, 2.5 or 3.

80
Figure: 6.8 Line and Paragraph Spacing

Text direction can also be changed.

 Select the test whose direction is to be changed


 Go to Home tab then in Paragraph group
 Select Text Direction and choose one option from the listed options

Figure: 6.9 Text Direction

After selecting from Text Direction, the text’s direction will be changed on slide.
To change the alignment of text within the text box, follow the following steps;
 Select the text. Go to Home tab then in “Paragraph” group.
 Click on “Align Text” option. Select any one option.

81
Figure: 6.10 Align Text

Simple plain text can be converted into SmartArt.

 Select the text. Go to “Home” tab.


 Go to “Paragraph” group and select the “convert to SmartArt” option.
 PowerPoint will list different types of SmartArt graphics.
 You can convert your SmartArt graphic back to text by right-clicking the graphic or
SmartArt shape and selecting Convert to Text.
 You will lose some text customizations, such as changes to the text color or font size that
you made to the text on the slide when you convert the text to a SmartArt graphic.
 After you select a layout for a SmartArt graphic, the text in your slides is automatically
put in shapes and arranged based on the layout that you chose. You can then customize
the SmartArt graphic by changing its color or by adding a SmartArt style to it.

You can change the colors applied to the shapes in your SmartArt graphic. The different color
combinations are all derived from the theme colors of your presentation.
1. Click the SmartArt graphic.
2. Under SmartArt Tools, on the Design tab, in the SmartArt Styles group, click Change
Colors.

Figure: 6.11 Smart Art Styles

If you don't see the SmartArt Tools or Design tabs, make sure that you've selected a SmartArt
graphic. You may have to double-click the SmartArt graphic to select it and open the Design tab.

82
3. Click the color variation that you want.

The figure shown below states the conversion of the text into SmartArt. It shows how the plain
bulleted text is converted into a professional design.

Figure: 6.12 Smart Art Designs

“Drawing” Group of home tab is used to create different type of shapes like square etc.

Figure: 6.13 Drawing

Shape outline, color and effects can be changed using the same group in Home Tab.
Find Replace option in editing group:

1. On the “Home” tab of the Ribbon, go to the “Editing” group, and select “Find” … or use the
shortcut key CTRL+F.
2. Type the word you want to find, and then press enter.

If you want to make a change to a specific word, you want to use the replace functionality. To
replace a word/s in PowerPoint:

1. Go to the “Editing” group, and select “Replace”, or use the shortcut key CTRL+H
2. In the “Find what” text box, type the word you want to find

83
3. In the “Replace with” text box, type the word that you want to replace the original word with
4. To replace words one at a time, click “Replace”, if you want to replace every occurrence of the
word in the document, click “Replace All”

Figure: 6.14 Editing

Insert Tab

First group in insert tab is “Tables”. On selecting the “table”, different option will appear from
where rows and columns can be selected.

 Click on the arrow underneath Table. This will open up a new box with several options
for creating a table.
 If you select the Insert Table option, a dialog box will appear where you can enter more
exact specifications for the table.

Figure: 6.15 Insert Table

Next group is “Images” group. Any picture placed in any directory of the computer can be
accessed using “Picture” option of this group and can be inserted in slides. Similarly Clipart can
also be inserted using this group.

84
Figure: 6.16 Insert Images

It has an option of getting Screenshots. PowerPoint will automatically take the screenshots of
already opened windows and gives the option to select the screenshot and insert in slide.

To create a photo album


 Go to “Images” group of “Insert” tab.

Click on the. It will give an option to create a new album or edit the existing one.
 On clicking the new photo album, the dialogue box is opened

Figure: 6.17 Photo Album

On selecting multiple files for album, a new presentation will be generated having all those
selected pictures.

Shapes, SmartArt and charts can be inserted using the “Illustrations” group of the “Insert” tab.
Adding Audio / Video to PowerPoint presentation:

1. Click on the Insert tab of the ribbon.


2. Click on the Movie or sound button in the media clip group to insert video or audio in
Presentation.
3. There are different options available for inserting audio or video to PowerPoint slides.

85
4. If you want to hide the audio file during slide show, select “Automatically” from Play sound
drop down menu and check the Hide during show option in the sound options group

Figure: 6.18 Video from file

Adding Hyperlink:

Select the text or image to link to insert a hyperlink. From right-click menu, click Hyperlink
option

Figure: 6.19 Hyperlink

This will bring up Insert Hyperlink dialog, from left side bar, select place in This Document,
from center pane, select a slide to create link with and click OK.

86
Figure: 6.20 Insert Hyperlink

This will insert a hyperlink in a specified slide.


Using “Text” group of “Insert” tab we can insert different text boxes, slide number and word art
etc.

Figure: 6.21 Insert Tab

Similarly, different equations can be inserted or created in the slide

Task:
1) Create Photo Album & Hyperlink

 Insert one new slide and put a text for example: “My Photo Album”
 Create one photo album and adjust your text and your photos
 Save your photo album with a new file
 Make a hyperlink to your photo using the text “My Photo Album”
Solution

87
2) Convert “text” into “SmartArt” and write down how you did this.

Solution

88
3) Insert the following equation

Solution

89
4) Insert the slide number, footer (your enrollment) and date. Write your name
and rotate it to 270o.
Solution

90
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

Lab Assessment Rubric

91
Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)
improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 07

92
Introduction to MS Office Excel

Objectives

MS Excel is spreadsheet software in the Microsoft Office Suite. Excel allows you to store
manipulate and analyze data in organized workbooks for home and business tasks

Equipment /tool Used


 Computer with any version of windows installed
 MS Office (MS Excel)
Background
Microsoft Excel is a spreadsheet developed by Microsoft for Windows, macOS, Android and
iOS. It features calculation, graphing tools, pivot tables, and a macro programming language
called Visual Basic for Applications. It has been a very widely applied spreadsheet for these
platforms, especially since version 5 in 1993, and it has replaced Lotus 1-2-3 as the industry
standard for spreadsheets. Excel forms part of Microsoft Office.

Figure: 7.1 Overview

To begin, open Excel 2016

Creating New Blank Workbook


a. At the top-left of your screen, you will see a File Button. Click on that Button and select new
b. Select ‘Blank Workbook’ from the window that appears, and click create
c. A new Excel workbook opens

93
Opening an Existing Workbook
a. Go to the File Button menu and click on ‘Open’
b. A window appears with some path set (typically ‘My Documents’). The left-hand side of
the window shows some links that allow you to browse through different folders and
change the path
c. Go to the folder where the workbook you want to open is located, select the workbook
and click open

A. Inside Home tab


a. In the Home tab you will see different sections ‘Clipboard’, ‘Font’, ‘Alignment’,
‘Number’, ‘Styles’, ‘Cells’ and ‘Editing’.
b. Each section has different buttons. When you place mouse pointer over a button for two
seconds, a description of the button appears. Try placing the pointer over different buttons
and read the description of each button.

I. Exploring the Fonts Section


a. Make the text bold by selecting some text and clicking on ‘B’.
b. Italicize the text by selecting some text and clicking on ‘I’
c. Similarly, you can underline by clicking ‘U’, add border to cell. Change the font –type
or the font-size. You can change the color of the text or highlight the text.
d. Inside the Font section, click on the little arrow in the bottom right to explore more
options.

II. Exploring Alignment section

a. Text Alignment
 You can left align text
 You can right align text
 You can center align you text
 You can top align text
 You can middle align text
 You can bottom align you text
b. You can change text orientation, wrap text and merge & center multiple cells as well

III. Exploring Alignment section

Explore the use of


‘Increase indent’ button.
‘Decrease indent’ button

IV. Creating New Sheet

You can create multiple sheets within a single workbook

94
Figure: 7.2 Sheet

B. Page Layout Section


 This tab is majorly used to set the margins, orientation and background of the
spread sheet.
 There is an option “Print Area” in page setup group. By using this option we can
select the area for printing purpose
C. Formula Section
• We can apply different formulas using this tab. Function library group is one of the
mostly used groups

Figure: 7.3 Toolbox

Use of Basic Statistics


You can use most common statistical metrics.
• Mean  Average ()
• Sum of points / no. of points
• E.g. you have points, 4, 5, 6 then mean = (4+5+6)/3 = 5
• =Average ()
• Min/Max  minimum or maximum
• Max (4, 5, 6) = 6
• Min (4, 5, 6) = 4
• Standard Deviation  How wide-spread the data is.
• Bigger the spread, higher the standard deviation.
• Size of dataset also effects value of standard deviation.
If we only have a few numbers ranging between 1 and 10 for example, the standard deviation
will likely be higher than if we have thousands of numbers ranging between 1 and 10. For
example,
Both these sets A and B have an average of 5. But A has a standard deviation of 0.7 while B has a
standard deviation of 4.1. Excel has a simple function to calculate the standard deviation of a set
of points:
=stdev ()

Insert a linked Excel chart in PowerPoint


You can insert and link a chart from an Excel workbook into your PowerPoint presentation.
When you edit the data in the spreadsheet, the chart on the PowerPoint slide can be easily
updated.

95
1. To chart your data in a worksheet
a) Make this table in Excel worksheet

Figure: 7.4 Excel worksheet

b) Select the data that you want to chart

Figure: 7.5 Excel worksheet

c) On the Insert tab, in the Charts group, click the chart type that you want to use, and then
click a chart subtype.

Figure: 7.6 Chart

To insert a linked Excel chart in PowerPoint


a) Open the Excel workbook that has the chart that you want.
Notes:
• The workbook must be saved before the chart data can be linked in the PowerPoint
file.
• If you move the Excel file to another folder, the link between the chart in the
PowerPoint presentation and the data in the Excel spreadsheet breaks.
b) Select the chart.
c) On the Home tab, in the Clipboard group, click Copy
d) Open the PowerPoint presentation that you want and select the slide that you want to
insert the chart into.
e) On the Home tab, in the Clipboard group, click the arrow below Paste, and then do one of
the following:

96
a. If you want the chart to keep its look and appearance from the Excel file,
select Keep Source Formatting & Link Data
b. If you want the chart to use the look and appearance of the PowerPoint
presentation, select Use Destination Theme & Link Data
f) You can edit chart data in PowerPoint or in Excel by pressing Right Click->Edit Data

Figure: 7.7 Charts in PowerPoint

Copying chart as a picture from Excel sheet


• Use the option of Special Paste.

Figure: 7.8 Charts in PowerPoint Special Paste

Tasks:

1) Sinusoidal Curves: Generate and plot a 101 sampled sine and a cosine wave of 5 Hz
frequency as shown below


• where = 5 Hz

• ranges from 0 to 1 in step of 0.01

97
Figure: 7.9
Solution

98
2) Generate a plot of following polynomials

where ranges from -50 to 50 in step of 1


Solution

99
3) Grade sheet
• Create a data that represents the marks obtained by the students in
HomeWork#1, HomeWork#2 and HomeWork#3 (The marks obtained are out of
10 for each homework)
• Add the data for 10 students, the columns hold categories of the data like:
Students | Name | HW # 1 | HW # 2 | HW # 3
• Apply functions on the data such that
• Fifth column contains the total marks obtained by a student in all
the 3 homework.
• Sixth column contains the average of the marks obtained.
• Seventh column contains the percentage.
• Eighth column contains the maximum marks obtained by a
student.
• Ninth column contains the minimum marks obtained by a student.
Solution

100
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

101
Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

102
Trouble Shooting Can clearly Sufficiently Describe the Cannot describe
identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 08

Fundamentals of Pseudo-codes

Objectives

The purpose is to gain fundamental skills to plan the logic of a program by ways of developing
simple logical statements.

Equipment /tool Used


 Computer with any version of windows installed
 MS Office (MS Word)

Background
Pseudo code
Pseudo code omits programming level details (like declaration of variables, looping syntax ...)
and so it makes things very easy to understand for human being and implement it in any
programming language easily.

103
Rules for Pseudo-codes
• Write only one statement per line
• Each statement in your pseudo code should express just one action for the
computer.
• Capitalize initial keyword
• READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE, REPEAT, UNTIL
• End multiline structures
• Use END in IF/ELSE conditions and main program
Example-1
Read a number from user and print it on console

Figure: 8.1 Pseudocode

Pseudocodes describes the logic flow in which the program is executed

EXAMPLE 2:

104
Figure: 8.2 Pseudocode with if condition

EXAMPLE 3:

Nesting if statements

Figure: 8.3 Pseudocode with nested if condition

Tasks:

1. Read in a number and check if the number entered by user is odd or even.
Solution

2. Read in two numbers, call them A and B. If A is greater than B, print out A, otherwise print out
B.

Solution

105
3. Read in a number and display the grade of a student.
Solution

4. Write a program to print the number entered by the user only if the nu mber entered
is negative.

Solution

5. Read in three numbers, call them A, B and C


 If A is bigger than B, then if A is bigger than C, print out A, otherwise print
out C.
 If B is bigger than A, then if B is bigger than C, print out B, otherwise print
out C.
Solution

106
6. Display your name and class

Solution

7. Read in the variables and find the area of triangle.

Solution

107
8. Read in the variables ‘x’ and ‘y’ and get their sum if x>y.

Solution

Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe

108
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 09

Algorithm development through Visual Logic

Objectives

109
It is a tool for creating program flowcharts. It helps to gain fundamental skills to plan the logic of
a program by ways of developing an algorithm in the form of flowchart.

Equipment /tool Used


 Computer with any version of windows installed
 Visual Logic (http://www.visuallogic.org/download).

Background
The programming process follows a program development lifecycle with its initial steps as
understanding the problem and planning the logic. This session focuses on ‘planning the logic’
where we will learn how to develop an algorithm in the form of flowchart

Symbols Used in Flowchart

Figure: 9.1 Symbols used in Flowcharts

VISUAL LOGIC SYNTAX

The starting flowchart displays a “Begin” and “End” symbol as shown. To create a flowchart,
you add symbols between these starting symbols.

110
Hover your mouse over the red arrow between the Begin and End symbols. It will turn green,
indicating that you can click on it to get a popup window. This popup window has the other
symbols we will need to create programs.

Figure: 9.2 Visual logic options

Click on the green arrow and select the Output symbol.


This inserts the Output symbol into the flowchart as shown. The Output symbol produces output
on the display screen. Next, we will specify what the program should output.

Figure: 9.3 Basic Visual logic flowchart

Double click on the Output symbol to get the Output dialog box.

Figure: 9.4 Visual logic Output

Enter your own name and be sure to enclose it within quotes. Later, we will use variables that
don’t use quotes. Click on the “OK” button when done, and the Output symbol will change to

111
show your intended output. Run the program by clicking on the button on the toolbar, or
by pressing the F5 function key.

Example of flowcharts

Figure: 9.5 Example of Flowchart

112
Tasks
1) Develop the logic of a program that takes two numbers and display their multiplication
Solution

2) Develop the logic of a program that takes the radius and height of a cylinder and
calculate its volume

Solution

113
3) Write an algorithm that sums all the even numbers between 1 and 20, and
then displays the sum
Solution

4) Draw flowchart to find the largest among three different numbers entered by
user.
Solution

114
5) Develop the logic of program to check input characters as vowel or consonants.
Solution

6) Develop the flowchart to convert Fahrenheit temperature to Celsius


Solution

115
7) Develop the flowchart that swaps the values in two variables
Solution

116
8) Develop the logic of program to prints out if the number entered is negative
Solution

Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

117
Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

118
Trouble Shooting Can clearly Sufficiently Describe the Cannot describe
identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 10

Introduction to Visual Studio and code debugging

Objectives

The purpose of the lab is to get started with the basics of programming language and to get
familiar with debugging the code.

Equipment /tool Used


 Computer with any version of windows installed
 Visual studio 2010/2015 Professional

Background
Introduction to C/ C++ Language
C is developed by Dennis Ritchie at AT&T Bell Labs in 1970s which used to maintain UNIX
systems. Many commercial applications are written in C.

119
C++ was developed by Bjarne Stroustrup at AT&T Bell Labs in the 1980s. This overcame
several shortcomings of C. It also incorporated object-oriented programming .C remains a subset
of C++. ‘++’ is an operator in C++.
The Computer Onion

Figure: 10.1 Computer Onion

Program Elements
A basic program has following elements:
1) Comments declared as //, /* */
2) Include files
3) Function including exactly one main function
4) Main function contains code or logic of your program being written in programming
language

cout and cin


 cout is a standard console output stream object.
 Used with insertion operator ‘<<‘ to display output on the console.
 Insertion operator sends the variable data from its right side to the left side.
 cin is a standard console input stream object
 Used with the insertion operator ‘>>’ to read any number, character from user

Variables
• Variables are used to hold values
• The values can be of certain types e.g. it can be numbers, characters etc.
• To hold each value uniquely, each variable is initialized with a data type
For example:
int a = 10;
float b = 0.5;
char c = ‘a’;

A Basic Program in C++

120
Figure: 10.2 Basic Program

Figure: 10.3 Basic Program

Output

121
Figure: 10.4 Output

Bugs and Debugging

The errors in programming are called bugs. The process of tracking bugs and removing them is
called debugging. Three kinds of errors can occur in a program

1) Syntax Errors

2) Semantic Errors

3) Runtime Errors

1. Syntax Errors: These errors occur when you didn’t follow the syntax of the
programming language. The program will not be compiled if you don’t remove them.
Syntax errors in English language are e.g. Hailo, haow r yeow?

2. Semantic Errors: These are also known as logical errors. The program will compile and
run successfully but it will not do the intended task. This is because there will be an error
in the logic (content) of the program. Debugging logical errors can be tricky because it
requires you to scan the code logically to look for the mistakes. With experience, you will
learn to overcome them easily.

3. Runtime Errors: These errors come at the program execution stage. They are also
known as “Exceptions”. They usually come if the program flow goes out of the expected
order. They are usually rare.

122
Code debugging: It is helpful to detect logical and run time errors from the code. It can also
provide step by step code monitoring. This requires that you add breakpoints at the desired line
of code. Press F11 key to check result at each statement. Press F10 key to execute line of codes
in the current function.

Introduction to Visual Studio

Programming IDE was developed by Microsoft. They used to implement different interactive
software. Visual Studio is an integrated development environment (IDE) that provides a mean to
tell a computer how to do something. Commonly supported languages in VS are: C, C++,
C#.NET and Visual Basic.NET, JavaScript, Python etc.

Figure: 10.5 Visual Studio Overview

123
Figure: 10.6 New Project

Figure: 10.7 New Project Screen

124
Example

Print “Hello C++ World” in Visual Studio using C++ and debug it

Example

Write a C++ program to take a weighted average of two numbers x1 and x2 such that x1 has 70%
weightage.

Task:

1. Develop a program that takes two numbers and display their multiplication

Solution

2. Develop the logic and write a program that takes the radius and height of a cylinder
and calculate its volume

Solution

125
3. Write a program that sums all the even numbers between 1 and 20, and then
displays the sum.
Solution

4. Develop a program to convert Fahrenheit temperature to Celsius


Solution

126
5. Develop the flowchart that swaps the values in two variables
Solution

127
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

128
Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

129
EXPERIMENT 11

Programming basics (operators, console input/output, logic development)

Objectives

The purpose of the lab is to get familiar with operators more thoroughly and sharpen the skill of
logic development through visual studio C++ programming.

Equipment /tool Used


 Computer with any version of windows installed
 Visual studio 2010/2015 Professional

Background
C++ Operators: An operator is simply a symbol that is used to perform operations. There can be
many types of operations like arithmetic, logical, bitwise etc. There are following types of
operators to perform different types of operations in C language.

1) Arithmetic Operators
2) Relational Operators
3) Logical Operators
4) Bitwise Operators
5) Assignment Operator
6) Unary operator
7) Ternary or Conditional Operator
8) Misc Operator

Figure: 11.1 Table of Operators

130
Task:

DEVELOP THE LOGIC AND THEN DEBUG THE CODE

1. Develop an algorithm and program that takes two numbers and display their
multiplication and sum.

Solution

2. The departmental store manager wants a program that calculates and displays the sale
price of a good when its cost price is entered. Sales price is the final price that has 15%
of GST added to cost price. Develop the logic of this program. Languages Allowed: C+
+

Solution

131
3. Develop an algorithm and then write a program that takes the length, width and height
of a room and calculate its volume and total surface area. Languages: C++

Solution

4. Body mass index (BMI) is a statistical measurement that compares a person’s weight
and height. To calculate BMI, you multiply your weight in pounds by 703 and divide the
result by the square of your height in inches. Develop the logic for a BMI calculator.
Language: C++

Solution

132
5. Develop a program that takes a three-digit number and display the sum of these
numbers. Languages: C++

Solution

133
6. If the marks obtained by a student in five different subjects are input through the
keyboard, write a program to find out the aggregate marks and average marks
obtained by the student. Assume that the maximum marks that can be obtained by a
student in each subject are 100. Take the aggregate sum in ‘int’ and average in float.
Type cast from int to float to take average. Language Allowed: C++

Solution

134
7. Write a program that asks the user to enter a US dollar amount and then shows how to
pay that amount using the smallest number of $20, $10, $5, and $1 bills.

For example, see the sample execution of program below:


Enter a dollar amount: 93
$20 bills: 4
$10 bills: 1
$5 bills: 0
$1 bills: 3
Solution

135
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

136
Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

137
Conclusions Thorough Good Limited Shows incorrect
understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 12

Decision Structures (if, if-else)

Objectives

The purpose of the lab is to get familiar with decision making conditions through the skill of
logic development using visual studio C++ programming.

Equipment /tool Used


 Computer with any version of windows installed
 Visual studio 2010/2015 Professional

Background
There come situations in real life when we need to make some decisions and based on these
decisions, we decide what should we do next. Similar situations arise in programming also where
we need to make some decisions and based on these decisions we will execute the next block of
code.
Decision making statements in programming languages decides the direction of flow of program
execution. Decision making statements available in C++ are:
 if statement
 if-else statements
 nested if statements
 if-else-if ladder
 switch statements

 if statement
if statement is the simplest decision-making statement. It is used to decide whether a certain
statement or block of statements will be executed or not i.e. if a certain condition is true then a
block of statement is executed otherwise not.

138
Syntax:
if(condition)
{
// Statements to execute if
// condition is true
}

if(condition)
statement1;
statement2;

// Here if the condition is true, if block


// will consider only statement1 to be inside
// its block.

Example:

/ C++ program to illustrate If statement


#include<iostream>
using namespace std;

int main()
{
int i = 10;

if (i > 15)
{
cout<<"10 is less than 15";
}

cout<<"I am Not in if";

139
}
Output:

I am Not in if

As the condition present in the if statement is false. So, the block below the if statement is not
executed.
 if- else
The if statement alone tells us that if a condition is true it will execute a block of statements and
if the condition is false it won’t. But what if we want to do something else if the condition is
false. Here comes the else statement. We can use the else statement with if statement to execute a
block of code when the condition is false.

Syntax:

if (condition)
{
// Executes this block if
// condition is true
}
else
{
// Executes this block if
// condition is false
}

Example:

// C++ program to illustrate if-else statement


#include<iostream>
using namespace std;

int main()
{
int i = 20;

140
if (i < 15)
cout<<"i is smaller than 15";
else
cout<<"i is greater than 15";

return 0;
}
Run on IDE
Output:

i is greater than 15

The block of code following the else statement is executed as the condition present in
the if statement is false

Task

1. Write a C++ program to take a number from user and find out whether it is divisible by
3 or not.

Solution

2. Write a program that displays the grade of a student where the marks are input from
the keyboard. The grading pattern is as following:

141
>= 70 A

>=60 and < 70 B+

>=50 and < 60 B

>=40 and < 50 C

<40 F

A session of the program execution should print following:

Enter student marks: 56

The grade for 56 marks is B. Language Allowed: C++

Solution

142
3. Write a program that converts an upper-case letter into a lower-case letter. (Hint: upper
case letter + 32 gives lower case). Language: C++

Solution

143
4. Write a program for a simple calculator. The program should take two float values and
the operation to be performed (char) from the user. The calculator should perform
addition, subtraction, multiplication and division. Example execution

Enter first number: 4

Enter Second number: 10

Enter operation to be performed (Select from +, -,*, /): +

Result: 14.

Solution

144
5. Write a program for an insurance company that allows only people from a certain age
group to be eligible for a specific insurance scheme. If the age is greater than 45 or less
than 25 it says you are not eligible. Else it prints you are eligible. Language: C++

Solution

145
6. The following table shows telephone area codes in the state of Georgia along with the
largest city in each area:

Area code City


229 Albany
404 Atlanta
470 Atlanta
478 Macon
678 Atlanta
706 Columbus
762 Columbus
770 Atlanta
912 Savannah

Write a C++ program that inputs the city area code and prints the corresponding city
name.

Solution

146
7. Write a program that determines the wages of a person based on working hours. If a
person works for less than 5 hours his wage per hour is Rs. 400. If he works for more
than 5 and less than 8 hours wage per hour increases to Rs.560. An addition of Rs. 2000
is given as overtime for workers who work up till 12 hours.

Solution

147
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

148
Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

149
Trouble Shooting Can clearly Sufficiently Describe the Cannot describe
identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

EXPERIMENT 13

Decision Structures (Nested if, Nested if-else, switch statement)

Objectives

The purpose of the lab is to get familiar with decision making conditions through complex
problems using visual studio C++ programming.

Equipment /tool Used


 Computer with any version of windows installed
 Visual studio 2010/2015 Professional

Background

 nested-if
A nested if is an if statement that is the target of another if statement. Nested if statements mean
an if statement inside another if statement. Yes, C++ allows us to nest if statements within if
statements. i.e., we can place an if statement inside another if statement.
Syntax:

150
if (condition1)
{
// Executes when condition1 is true
if (condition2)
{
// Executes when condition2 is true
}
}

Example:
// C++ program to illustrate nested-if statement
int main()
{
int i = 10;

if (i == 10)
{
// First if statement
if (i < 15)
cout<<"i is smaller than 15";

// Nested - if statement
// Will only be executed if statement above
// it is true
if (i < 12)
cout<<"i is smaller than 12 too";
else
cout<<"i is greater than 15";
}

return 0;
}
Output:

i is smaller than 15
i is smaller than 12 too

 if-else-if ladder

151
Here, a user can decide among multiple options. The if statements are executed from the top
down. As soon as one of the conditions controlling the if is true, the statement associated with
that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then
the final else statement will be executed.

Syntax:
if (condition)
statement;
else if (condition)
statement;
.
.
else
statement;

Example:
// C++ program to illustrate if-else-if ladder
#include<iostream>
using namespace std;

int main()
{
int i = 20;

if (i == 10)
cout<<"i is 10";
else if (i == 15)
cout<<"i is 15";
else if (i == 20)
cout<<"i is 20";
else
cout<<"i is not present";
}
Output:

i is 20

 Switch Statement in C/C++


Switch case statements are a substitute for long if statements that compare a variable to several
integral values. The switch statement is a multiway branch statement. It provides an easy way to

152
dispatch execution to different parts of code based on the value of the expression. Switch is a
control statement that allows a value to change control of execution.
Syntax:

switch (n)
{
case 1: // code to be executed if n = 1;
break;
case 2: // code to be executed if n = 2;
break;
default: // code to be executed if n doesn't match any cases
}

Important Points about Switch Case Statements:


 The expression provided in the switch should result in a constant value otherwise it
would not be valid.
Valid expressions for switch:
// Constant expressions allowed
switch(1+2+23)
switch(1*2+3%4)

Invalid switch expressions for switch:


// Variable expression not allowed
switch(ab+cd)
switch(a+b+c)

 Duplicate case values are not allowed.


 The default statement is optional. Even if the switch case statement does not have a
default statement, it would run without any problem.
 The break statement is used inside the switch to terminate a statement sequence. When a
break statement is reached, the switch terminates, and the flow of control jumps to the next
line following the switch statement.
 The break statement is optional. If omitted, execution will continue into the next case.
The flow of control will fall through to subsequent cases until a break is reached.
 Nesting of switch statements are allowed, which means you can have switch statements
inside another switch. However nested switch statements should be avoided as it makes
program more complex and less readable.

153
Example:
// Following is a simple program to demonstrate
// syntax of switch.
#include <stdio.h>
int main()
{
int x = 2;
switch (x)
{
case 1: printf("Choice is 1");
break;
case 2: printf("Choice is 2");
break;
case 3: printf("Choice is 3");
break;
default: printf("Choice other than 1, 2 and 3");
break;
}
return 0;
}
Output:

Choice is 2

Task
1. Write a program for a simple calculator. The program should take two float values and
the operation to be performed (char) from the user. The calculator should perform
addition, subtraction, multiplication and division. (Use Switch Statements)
Example execution
Enter first number: 4
Enter Second number: 10
Enter operation to be performed (Select from +, -, *, /): +
Result: 14.
Solution

154
2. Write a program to calculate and display the sum of 1 to n in steps of s, where n and s
are numeric-type arguments input from the keyboard such that s denotes the step size
between 1 and n. For example, if n=21 and s=3 are passed, it will display the result of 1
+ 4 + 7 + 10 + 13 + 16 + 19
Solution

155
3. Two numbers x and y are entered through the keyboard. Write a program to find the
value of x raised to the power of y
Solution

156
4. Write a program that asks the user for a two-digit number (i.e. between 10-99), then
prints the English word for the number:
Enter a two-digit number: 45
You enter the number forty-five.
Hint: Break the number into two digits. Use one switch statement to print the word for the
first digit (“twenty”, “thirty”, and so forth). Use a second switch statement to print the word for the
second digit. Don’t forget that the numbers between 11 and 19 require special treatment. This
needs special attention.
Solution

157
5. Use nested loop to print the truth table of three 1-bit inputs
Solution

158
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

159
Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real

160
life situations situations knowledge.

Lab No: _______ Total Marks: __________ Signature: _____________

EXPERIMENT 14

Basics of MATLAB

Objectives

The purpose of the lab is to get familiar with an engineering tool MATLAB. They will be
familiarized with MATLAB interface and its basic features.

Equipment /tool Used


 Computer with any version of windows installed
 MATLAB 2016b

Background
MATLAB, which stands for Matrix Laboratory, is a state-of-the-art mathematical software
package, which is used extensively in both academia and industry. It is an interactive program
for numerical computation and data visualization, which along with its programming capabilities
provides a very useful tool for almost all areas of science and engineering
Therefore, learning MATLAB is extremely essential for electrical engineering students.
MATLAB Interface:

161
Figure: 14.1 MATLAB Interface

The desktop has the following panels –


Current Folder − This panel allows you to access the project folders and files.

Command Window − This is the main area where commands can be entered at the command
line. It is indicated by the command prompt (>>).

162
Figure: 14.2 Command Window

Workspace − The workspace shows all the variables created and/or imported from files.

Figure: 14.3 Workspace

Command History − This panel shows or rerun commands that are entered at the command
line.

163
Figure: 14.4 Command History

Getting Started
If you don’t know anything about MATLAB, then MATLAB help is the best way to learn about
something. In the command window of MATLAB simply write ‘help’;

>> help 
It will display list of all toolboxes included in MATLAB. Then by investigating the name of
toolbox or the name of a function, which you would like to learn how to use, use the ‘help’
command:

>> help functionname 


This command displays a description of the function and generally also includes a list of related
functions. If you cannot remember the name of the function, use the ‘lookfor’ command and the
name of some keyword associated with the function:

>> lookfor keyword 


This command will display a list of functions that include the keyword in their descriptions.
Other help commands that you may find useful are ‘info’, ‘what’, and ‘which’. Descriptions of
these commands can be found by using the help command. MATLAB also contains a variety of
demos that can be with the ‘demo’ command.
Data storage in MATLAB:
MATLAB stores variables in the form of matrices, which are M x N, where M is the number of
rows and N the number of columns. A 1x1 matrix is a scalar; a 1xN matrix is a row vector, and
Mx1 matrix is a column vector. All elements of a matrix can be real or complex numbers; -1
can be written as either ‘i’ or ‘j’ provided the user does not redefine them. A matrix is written
with a square bracket ‘[ ]’ with spaces separating adjacent columns and semicolons separating
adjacent rows. For example, consider the following assignments of the variable x
Real scalar >> x = 5
Complex scalar >> x = 5+10j (or >> x = 5+10i)
Row vector >> x = [1 2 3] (or x = [1, 2, 3])
Column vector >> x = [1; 2; 3]
3 x 3matrix >> x = [1 2 3; 4 5 6; 7 8 9]
There are a few notes of caution. Complex elements of a matrix should not be typed with spaces,
i.e., ‘-1+2j’ is fine as a matrix element, ‘-1 + 2j’ is not. Also, ‘-1+2j’ is interpreted correctly
whereas ‘-1+j2’ is not (MATLAB interprets the ‘j2’ as the name of a variable. You can always
write
‘-1+j*2’.

164
Complex number operations:
Some of the important operations on complex numbers are illustrated below:
Complex scalar >> x = 3+4j
Real part of x >> real(x) = 3
Imaginary part of x >> imag(x) = 4
Magnitude of x >> abs(x) = 5
Angle of x >> angle(x) = 0.9273
Generating Vectors:
Vectors can be generated using the ‘:’ command. For example, to generate a vector x that takes
on the values 0 to 10 in increments of 0.5, type the following, which generates a 1 x 21 matrix?
>> x = [0:0.5:10];
Other ways to generate vectors include the commands: ‘linspace’ which generates a vector by
specifying the first and last number and the number of equally spaced entries between the first
and last number, and ‘logspace’ which is the same except that entries are spaced logarithmically
between the first and last entry.
Accessing Vector Elements:
Specifying the row and column accesses elements of a matrix. For example, in the matrix
specified by A = [1 2 3; 4 5 6; 7 8 9], the element in the first row and third column can be
accessed by following command
>> x = A(1,3) which yields 3
The entire second row can be accessed with
>> y = A(2,:) which yields [4 5 6]
Where the ‘:’ here means “take all the entries in the column”. A sub-matrix of A consisting of
rows 1 and 2 and all three columns is specified by
>> z = A(1:2,1:3) which yields [1 2 3; 4 5 6]
Matrix Operations:
MATLAB contains several arithmetic, relational, and logical operations on matrices.
Arithmetic Operations
The basic arithmetic operations on matrices (and of course scalars, which are special cases of matrices)
are:

165
+ Addition

- Subtraction

* Multiplication

/ Right division

\ Left division

Exponentiation
^
(power)

Con

jugate transpose

An error message occurs if the sizes of matrices are incompatible for the operation. Division is
defined as follows: The solution to A * x = b is x = A\b and the solution to x *A = b is x = b/A
provided A is invertible and all the matrices are compatible.
Addition and subtraction involve element-by-element arithmetic operations; matrix
multiplication and division do not. However, MATLAB provides for element-by-element
operations as well by prep ending a ‘.’ before the operator as follows:

.* Multiplication

./ Right division

.\ Left division

.^ Exponentiation (power)

.‘ Conjugate transpose

The difference between matrix multiplication and element-by-element multiplication is seen in


the following example
>>A = [1 2; 3 4]
A= 12
34
>>B=A*A

166
B = 7 10
15 22
>>C=A.*A
C= 14
9 16
Relational Operations:
The following relational operations are defined:

< Less than

<= Less than or equal to

> Greater than

>= Greater than or equal to

== Equal to

~= Not equal to

These are element-be-element operations, which return a matrix of ones (1 = true) and zeros
(0 = false). Be careful of the distinction between ‘=’ and ‘= =’.
Flow and control operations:
MATLAB contains the usual set of flow control structures, e.g., for, while, and if, plus the
logical operators, e.g., & (and), | (or), and ~ (not).
Math functions:
MATLAB comes with a large number of built-in functions that operate on matrices on an element-by
element basis. These include:

Sin Sine

Cos Cosine

Tan Tangent

Asin Inverse sine

Acos inverse cosine

167
Atan inverse tangent

Exp exponential

Log natural logarithm

log10 common logarithm

Sqrt Square root

Abs Absolute value

Sign signum

Task:
1. Run the MATLAB help desk by typing helpdesk. The help desk provides a hypertext
interface to the MATLAB documentation.
Solution

168
2. Use MATLAB as a calculator. Try the following:
 pi*pi - 10
 sin(pi/4)
 ans ˆ 2 %<--- "ans" holds the last result
Solution

169
3. Do variable name assignment in MATLAB. Try the following:
 x = sin( pi/5 );
 cos( pi/5 ) %<--- assigned to what?
 y = sqrt( 1 - x*x )
 ans

Solution

170
4. Complex numbers are natural in MATLAB. The basic operations are supported. Try
the following:
 z = 3 + 4i, w = -3 + 4j
 real(z), imag(z)
 abs([z,w]) %<-- Vector constructor
 conj(z+w)
 angle(z)

Solution

171
172
5. Enter the following in MATLAB.

2 3 1 6
A=  ,B=
6 4 6
 2

Find A+B, A-B, AB, and A-1.


Solution

173
Conclusion:

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

______________________________________________________________________________

174
Lab Assessment Rubric

Category Excellent 8 Good 6 Satisfactory 4 Needs Total (40)


improvement 2
Objectives and Clearly describes Adequately Describes the Cannot describe
Results the objectives of describes the objectives but the objectives of
lab. Understands objectives, but misses some the lab, or what
possible sources cannot discuss details. Cannot was learnt,
of errors and possible discuss possible sources of errors
their effects. sources of sources of error and their effects
Suggests ways to errors and or their effects
minimize them. their effects

Software/Tool Given task works Given task has Task shows Task not
usage perfectly. some errors. some correct performed
outputs. correctly.

Trouble Shooting Can clearly Sufficiently Describe the Cannot describe


identify the identify problem but the problem and
problems and problems and cannot suggest has no effective
take steps to fix steps taken to steps on how to strategy on how to
them with fix them but solve them. solve them.
effective strategy misses some
details

Measurements Detailed results Adequate Some missing Most results are


and Observations are shown for results are observations. missing.
each step. shown.

Conclusions Thorough Good Limited Shows incorrect


understanding of understanding understanding understanding of
the lab concepts of the of the concepts. the concept.
Can apply it in concepts, but Cannot apply to Cannot find any
real life cannot apply real life usage of the
situations them in real situations knowledge.
life situations

Lab No: _______ Total Marks: __________ Signature: ______________

175
176

Vous aimerez peut-être aussi