0% found this document useful (0 votes)
26 views85 pages

Lab Manual Aict

Uploaded by

talha.nadeem9912
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views85 pages

Lab Manual Aict

Uploaded by

talha.nadeem9912
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 85

FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Application of Information and Communication Technology

Semester 1st

Name: _______________________________________________

Roll Number: _________________________________________

Computer Science Department


IQRA University, Karachi
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

List of Experiments
Lab No Topics Remarks Mapping
Learning basics of Microsoft Word
CLO_1

1.

Exploring the advanced features of Microsoft Word


CLO_2

2.

Working with Microsoft Excel


CLO_2

3.

Exploring the advanced features of Microsoft Excel


CLO_2

4.

Exploring the advanced features of Microsoft Excel contd


CLO_3

5.

Familiarization with the environment of Microsoft Power Point.


CLO-3

6.

Familiarization with the environment of Microsoft Power Point.


CLO_3
contd
7.

Creating databases using Microsoft Access


CLO-3

8.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Exploring the advanced features of Microsoft Access


CLO_3

9.

Creating queries, forms and reports in Microsoft Access.


CLO-3

10.

Getting familiar with the Turbo C Integrated


Development Environment. Installing and copying the CLO_3
11. compiler, changing directory settings.

Making first program in C. Saving / copying files to USB or


CLO-3
other storage devices.
12.

Understanding and Using format specifiers and escape sequences


with printf.
13. CLO_3

Studying different data types, variables, variable names, variable


declaration, variable definition, variable initialization, escape
14.
sequences.
CLO-3

15.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Course Name (Course Code) __________________ Semester ________ Batch _______


Name of Student: ___________________________________Roll No. ______________

Lab Description & Score

Programming/
1. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
2. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
3. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
4. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
5. Software Handling Results Lab Report Score
Simulations
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
6. Software Handling Results Lab Report Score
Simulations
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
7. Software Handling Results Lab Report Score
Simulations
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
8. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
9. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
10. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
11. Software Handling Results Lab Report Score
Simulations
( )/2 ( )/2 ( )/1 ( )/10
( )/5

12.
Software Handling Programming/ Results Lab Report Score
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Simulations
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
13. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5

Programming/
14. Software Handling
Simulations
Results Lab Report Score
( )/2 ( )/2 ( )/1 ( )/10
( )/5
TOTAL SCORE = 140 OBTAINED SCORE

Overall Score: ___________ out of 50 Examined by: _________________


Overall Formula= (Obtained Score / Total Score) x 50 (Name and Signature of Concerned)
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Introduction to Information and Communication Technology (3+1)

Instructor: Sumaira Ahmed Office Hours: ()

Prerequisite: None

Objectives:
Introduction to Computer & Programming is an introductory course on computers and its related fields. It gives
to the students the elementary knowledge of various computer related courses, which they study throughout
the four years of their stay at the university. Putting it the other way, this course helps students make
themselves acquainted with computer and information systems engineering. The objective of the practical
work presented in this workbook is to provide necessary laboratory assistance to the students regarding this
course.
Contents:
Section helps in exploring MS-Office 2013, various features of different application software part of it which are
helpful to a common computer user. This includes Microsoft Word, Excel, PowerPoint and Access. Learning
these software can help students in better documentation, preparation of their presentations and report work
for various courses.

Learning Outcomes:

Mapping of CLOs and PLOs

Sr. No Course Learning Outcomes PLOs Blooms Taxonomy

Apply different task MicroSoft office tools including


Microsoft word, Excel, Power point and Access.
CLO_1 PLO_1 C3 (Apply)

Understading of different IDEs and installation.


CLO_2 PLO_1 C2 (Understand)
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Basic knowledge of C programming language


with hands-on practice
CLO_3 PLO_3 C2 (Understand)

CLO Assessment Mechanism

Assessment tools CLO_1 CLO_2 CLO_3

Lab Manual

30% 30% 40%

Assignments/ viva/Quizzes

- - 40%

Final Examination

40% 60% -

Overall Grading Policy

Assessment Items Percentage

Lab Manual 30%


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Assignments/ viva/Quizzes 20%


Final Examination 50%

Recommended Book:
Introduction to Computers by Gary B. Shelly, Steven M. Freund, Misty E. Vermaat

Administrative Instructions:

▪ According to institute policy, 75% attendance is mandatory to appear in the final examination but
100% will be expected. Approved leaves will not be considered towards attendance.
▪ Every student should bring calculator, book and manual in each lab.

▪ Every student is expected to be in lab before schedule starting time.

▪ In any case there will be no rescheduling and makeup of labs.


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

General Laboratory Procedure


While there is no specific document to be submitted at the beginning of the Lab –unless your instructor advises
you otherwise-, you are expected to read the experiment fully before you come to the laboratory?
Interestingly, you can even try parts of the experiment at home. Here is a list of programs that will equip you
with a virtual lab at your home:
Troubleshooting
Things will not always go as expected; this is the nature of the learning process. While conducting the
Experiment think before you do anything. If you do so you will avoid wasting time going down dead-end
streets. Be logical and systematic. First, look for obvious errors that are easy to fix. Is your measuring device
correctly set and connected? Are you looking at the proper scale? Is the power supply set for the correct
voltage? Is the signal generator correctly set and connected? How are the variables in the code set? Is there a
syntax error? And so on. Next, check for obvious misconnections or broken connections, at least in simple
circuits.
As you work through your circuit, use your Lab Manual record tests and changes that you make as you go
along; don't rely on your memory for what you have tried. Identify some test points in the system at which you
know what the signal should be and work your way backwards from the output through the test points until
you find a good signal.
Neatness
When you have finished for the day, return all modules to their proper storage bins, return all test leads and
probes to their storage racks, return all equipment to its correct location, and clean up the lab station. If
appropriate switch off the unneeded equipment. Save your files in the Computer and on any USB device for
your records because you might not get the same PC System again for the next experiment. Also email your file
contents to your email address as a backup.
Laboratory Safety

Always pay attention to what you are doing and you’re surrounding during the experiments, notify the
Instructor for any unlikely event or mishap, and leave the Laboratory with the permission of Instructor
immediately.
All students must read and understand the information in this document with regard to laboratory safety and
emergency procedures prior to the first laboratory session.
Your personal laboratory safety depends mostly on YOU. Efforts have been made to address situations that
may pose a hazard in the lab but the information and instructions provided cannot be considered all-inclusive.
Students must adhere to written and verbal safety instructions throughout the academic term. Since additional
instructions may be given at the beginning of laboratory sessions, it is important that all students arrive at each
session on time. With good judgment, the chance of an accident in this course is very small. Nevertheless,
research and teaching workplaces (labs, shops, etc.) are full of potential hazards that can cause serious injury
and or damage to the equipment. Working alone and unsupervised in laboratories is forbidden if you are
working with hazardous substances or equipment. With prior approval, at least two people should be present
so that one can shut down equipment and call for help in the event of an emergency. Safety training and/or
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

information should be provided by a faculty member, teaching assistant, lab safety contact, or staff member at
the beginning of a new assignment or when a new hazard is introduced into the workplace.
Emergency Response
1. It is your responsibility to read safety and fire alarm posters and follow the instructions during an
emergency
2. Know the location of the fire extinguisher, eye wash, and safety shower in your lab and know how to use
them.
3. Notify your instructor immediately after any injury, fire or explosion, or spill.
4. Know the building evacuation procedures.
Common Sense
Good common sense is needed for safety in a laboratory. It is expected that each student will work in a
responsible manner and exercise good judgment and common sense. If at any time you are not sure how to
handle a particular situation, ask your Teaching Assistant or Instructor for advice DO NOT TOUCH ANYTHING
WITH WHICH YOU ARE NOT COMPLETELY FAMILIAR!!! It is always better to ask questions than to risk harm to
yourself or damage to the equipment.
Personal and General laboratory safety
1. Never eat, drink, or smoke while working in the laboratory.
2. Read labels carefully.
3. Do not use any equipment unless you are trained and approved as a user by your supervisor.
4. Wear safety glasses or face shields when working with hazardous materials and/or equipment.
5. Wear gloves when using any hazardous or toxic agent.
6. Clothing: When handling dangerous substances, wear gloves, laboratory coats, and safety shield or glasses.
Shorts and sandals should not be worn in the lab at any time. Shoes are required when working in the
machine shops.
7. If you have long hair or loose clothes, make sure it is tied back or confined.
8. Keep the work area clear of all materials except those needed for your work. Coats should be hung in the
hall or placed in a locker. Extra books, purses, etc. should be kept away from equipment that requires air
flow or ventilation to prevent overheating.
9. Disposal - Students are responsible for the proper disposal of used material if any in appropriate containers.
10.Equipment Failure - If a piece of equipment fails while being used, report it immediately to your lab
assistant or tutor. Never try to fix the problem yourself because you could harm yourself and others.
11.If leaving a lab unattended, turn off all ignition sources and lock the doors.
12.Never pipette anything by mouth.
13.Clean up your work area before leaving.
14.Wash hands before leaving the lab and before eating.
15.Unauthorized person(s) shall not be allowed in a laboratory for any reason
Electrical safety
1. Obtain permission before operating any high voltage equipment.
2. Maintain an unobstructed access to all electrical panels.
3. Wiring or other electrical modifications must be referred to the Electronics Shop or the Building
Coordinator.
4. Avoid using extension cords whenever possible. If you must use one, obtain a heavy- duty one that is
electrically grounded, with its own fuse, and install it safely. Extension cords should not go under doors,
across aisles, be hung from the ceiling, or plugged into other extension cords.
5. Never, ever modify, attach or otherwise change any high voltage equipment.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

6. Always make sure all capacitors are discharged (using a grounded cable with an insulating handle) before
touching high voltage leads or the "inside" of any equipment even after it has been turned off. Capacitors
can hold charge for many hours after the equipment has been turned off.
7. When you are adjusting any high voltage equipment or a laser which is powered with a high voltage supply,
USE ONLY ONE HAND. Your other hand is best placed in a pocket or behind your back. This procedure
eliminates the possibility of an accident where high voltage current flows up one arm, through your chest,
and down the other arm.
8. Discard damaged cords, cords that become hot, or cords with exposed wiring.
9. Before equipment is energized ensure, (1) circuit connections and layout have been checked by a Teaching
Assistant (TA) and (2) all colleagues in your group give their assent.
10. Know the correct handling, storage and disposal procedures for batteries, cells, capacitors, inductors and
other high energy-storage devices.
11. Experiments left unattended should be isolated from the power supplies. If for a special reason, it must be
left on, a barrier and a warning notice are required.
12. Equipment found to be faulty in any way should be reported to the Lab Engineer immediately and taken out
of service until inspected and declared safe.
13. Voltages above 50 V rms AC and 120 V DC are always dangerous. Extra precautions should be considered as
voltage levels are increased.
14. Never make any changes to circuits or mechanical layout without first isolating the circuit by switching off
and removing connections to power supplies.
15. Know what you must do in an emergency.
16. Emergency Power Off: Every lab is equipped with and Emergency Power Off System.
17. Only authorized personnel are permitted to reset power once the Emergency Power Off system has been
engaged.
Electrical Emergency Response
The following instructions provide guidelines for handling two types of electrical emergencies:
1. When someone suffers serious electrical shock, he or she may be knocked unconscious. If the victim is still
in contact with the electrical current, immediately turn off the electrical power source. If you cannot
disconnect the power source, depress the Emergency Power Off switch.
2. Do not touch a victim that is still in contact with a live power source; you could be electrocuted.
3. Have someone call for emergency medical assistance immediately. Administer first-aid, as appropriate.
4. If an electrical fire occurs, try to disconnect the electrical power source, if possible. If the fire is small and
you are not in immediate danger; and you have been properly trained in fighting fires, use the correct type
of fire extinguisher to extinguish the fire. When in doubt, push in the Emergency Power Off button.
5. NEVER use water to extinguish an electrical fire.

Mechanical safety
1. When using compressed air, use only approved nozzles and never direct the air towards any person.
2. Guards on machinery must be in place during operation.
3. Exercise care when working with or near hydraulically- or pneumatically-driven equipment. Sudden or
unexpected motion can inflict serious injury.
Additional Safety Guidelines
1. Never do unauthorized experiments.
2. Never work alone in laboratory.
3. Keep your lab space clean and organized.
4. Do not leave an on-going experiment unattended.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

5. Always inform your instructor if you break a thermometer. Do not clean mercury yourself!!
6. Never taste anything. Never pipette by mouth; use a bulb.
7. Never use open flames in laboratory unless instructed by TA.
8. Check your glassware for cracks and chips each time you use it. Cracks could cause the glassware to fail
during use and cause serious injury to you or lab mates.
9. Maintain unobstructed access to all exits, fire extinguishers, electrical panels, emergency showers, and eye
washes.
10.Do not use corridors for storage or work areas.
11.Do not store heavy items above table height. Any overhead storage of supplies on top of cabinets should be
limited to lightweight items only. Also, remember that a 36" diameter area around all fire sprinkler heads
must be kept clear at all times.
12.Areas containing lasers, biohazards, radioisotopes, and carcinogens should be posted accordingly. However,
do not post areas unnecessarily and be sure that the labels are removed when the hazards are no longer
present.
13.Be careful when lifting heavy objects. Only shop staff may operate forklifts or cranes.
14.Clean your lab bench and equipment, and lock the door before you leave the laboratory.
Clothing
1. Dress properly during a laboratory activity.
2. Long hair, dangling jewelry, and loose or baggy clothing are a hazard in the laboratory.
3. Long hair must be tied back, and dangling jewelry and baggy clothing must be secured.
4. Shoes must completely cover the foot.
5. No sandals allowed on lab days.
6. A lab coat or smock should be worn during laboratory experiments.
Accidents and Injuries
1. Do not panic.
2. Report any accident (spill, breakage, etc.) or injury (cut, burn, etc.) to the teacher
immediately, no matter how trivial it seems.
3. If you or your lab partner is hurt, immediately (and loudly) yell out the teacher's
name to get the teacher's attention.

General Warning Signs


FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science

CONTENTS
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Lab Session No. Object

Section One: Working with MS Office 2013


1 Learning basics of Microsoft Word
2 Exploring the advanced features of Microsoft Word
3 Working with Microsoft Excel
4 Familiarization with the environment of Microsoft Power Point
5 Creating databases using Microsoft Access
6 Creating queries, forms and reports in Microsoft Access

Section Two: C Language

7. Getting familiar with the Turbo C Integrated Development Environment. Installing and
copying the compiler, changing directory settings.

8. Understanding and Using format specifiers and escape sequences with printf.

9. Studying different data types, variables, variable names, variable declaration, variable definition, variable
initialization, escape sequences.

10. Studying Math functions.


11. Taking Input from the user at console screen using scanf and getche commands.

12. Arithmetic operators, conditional operators, assignment operators, Increment/decrement operators.

13. Studying loops. For loops, nested for loops, while loops, nested while loops, do while loops,
nested do while loops.

14. Decision making and conditioning using If statements, If-else statements, switch-case.
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science

Section One
Working with MS Office 2013
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science

Lab Session 01

OBJECT

Learning basics of Microsoft Word

WORD PROCESSING CONCEPTS

AutoComplete

As the user types, Word will automatically offer suggestions to complete the rest of a word or
phrase being typed after the first three or more letters of a common word or phrase have been
typed, thus enhancing typing speed.

Begin typing a common word, phrase, or AutoText entry; when the ScreenTip appear, press
Enter (or F3) to use the AutoComplete item, or continue typing to ignore it.

AutoText: Inserting/Creating/Editing

AutoText feature saves time by storing frequently used text and graphics (with or without
formatting) for the user to be used repeatedly.

To insert an AutoText entry, position the insertion point where the AutoText entry is to be
appeared; Type the name of the AutoText entry, then press F3 (the insert AutoText entry key).

To create an AutoText entry, select the text; choose Insert, Quick Parts, AutoText, Save
Selection to AutoText Gallery or press Alt+F3; Either type a new name for the AutoText
entry and click OK, or click OK to accept the name suggested by Word.

To edit an AutoText entry, select the AutoText entry to be changed and press Alt+F3. Type
the changed text including any blank lines or paragraph symbols if necessary in the
Description text box.

Indentation

To indent both the left and right sides of the paragraph, position the insertion point in the
paragraph to be indented, or select multiple paragraphs to indent; Choose Page Layout, type
or select a value in the Left and then the Right indentation text boxes. You can also increase
or decrease the indentation by clicking on the up and down arrows beside the text boxes.

Document Map
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

The Document Map is a very functional way to move quickly through long or online documents.
To use Document Map, choose View, Navigation Pane. Use the mouse to click the heading or text
in the Document Map pane to move to that section of the document; Click the arrow on the left of
any heading to expand or collapse the headings; To adjust the size of the
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science
Navigation pane, move the mouse pointer onto the right edge of the pane so the pointer
changes to a resizing pointer, then click and drag the edge to the left or right. To use the
keyboard, press F6 to move to the Navigation pane. Arrow keys and the Enter key will move
to the desired location in the document.

Alignment: Aligning Text

Word automatically aligns text on the left margin (horizontal alignment) and to the top margin
(vertical alignment). The user can choose to change the alignment to center, right, full
justified, or back to left.
To change horizontal alignment, select the paragraph(s) to be changed; Press Ctrl+L (Left),
Ctrl+E (Center), Ctrl+R (Right), or Ctrl+J (Justify) to change the alignment of the paragraph
accordingly (or use the Align Left, Center, Align Right, or Justify buttons on the Standard
toolbar).
To change vertical alignment, move the insertion point inside the section where the text is to
be aligned; Choose Page Layout, Align. Select Center, Justify, or Top to change alignment.

Case Changing

To change case, select the text whose case to be changed; Press Shift+F3 to change the case.
Each time F3 is pressed the user will toggle through three options: UPPERCASE, lowercase,
and Title Case.

Borders, Lines, and Shading: Adding

For a finished look, the user can add borders and shading to the documents. Just select the
paragraph(s) to apply a border or shading to, then choose Insert, Table and click on Insert
Table. In the title bar, there appears a Table Tools box. Click on this box. Click on Border and
then on Border and Shading. Then click the desired line style; Click the Line Weight button,
then click the line weight to be used; Click the drop-down arrow on the Borders button, then
click the type of border to be applied; Click the drop-down arrow on the Shading Color button
to display the palette of gray percent’s and colors, then click the percent of gray or color
button.

Columns

To create columns of equal width, choose Page Layout; Select the text (or to format the entire
document with columns, select the document); On the Standard toolbar, click the Columns
button; Drag the pointer to select the number of columns needed. To remove columns, select
the text for the columns to be removed; Click the Columns button on the Standard toolbar and
select one column.

Drop Cap
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

A drop cap is large capital letters of the first word that is set into a paragraph to add visual
interest. Just select the first letter, word, or section of the paragraph to be formatted with a drop
cap; Choose Insert, Drop Cap; Select Dropped or In Margin; In the Drop Cap Options section,
select the Font from the drop-down list, and increase or decrease the Lines to Drop if the default
of three lines is not to be used; If the distance of the text from the drop cap is to be changed, use
the increment buttons on the Distance from Text option, then choose OK. To remove drop
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science

caps, click the drop caps text, choose Drop Cap, click the None option in the Position section
of the dialog box, then choose OK.

Using Shortcut Keys

If the user is a touch typist, he may find that formatting characters and paragraphs using
keyboard shortcuts is easier and quicker than using the mouse, menus, and toolbars.
Following are some of the short keys Word uses:

Format Shortcut Format


Shortcut
Bold……………………………….Ctrl+B
Italic……………………………….Ctrl+I
Single underline…………………...Ctrl+U
Wordunderline…………………Ctrl+Shift+W
Double underline………………….Ctrl+Shift+D SMALL
CAPS…………………Ctrl+Shift+K
Superscript…………………………….Ctrl+Shift+=
Subscript………………………………Ctrl+=
Change case……………………….Shift+F3 Next larger point
size…………..Ctrl+Shift+>
Next smaller point size……………Ctrl+Shift+< Left
align…………………….……Ctrl+L
Right align……………………...…Ctrl+R
Center……………………………..Ctrl+E
Full justify…………………………Ctrl+J Increase indent…………….………Ctrl+M
Decrease indent……………………Ctrl+Shift+M Hanging
indent…………….………Ctrl+T
Decrease hanging indent…..………Ctrl+Shift+T Return to norma
formatting.………Ctrl+Q l

Customizing Paragraph Spacing

The user can customize the paragraph spacing in Word for the spacing between paragraphs
and the spacing between the lines in specified paragraphs. To do this, place the insertion point
in the paragraph to be modified, or highlight all of the contiguous paragraphs to be changed
and right click on it; Choose Paragraph to display the dialog box, then click the Indents and
Spacing tab if it is not active; In the Spacing section, select Before and After and change the
value(s) in the text box to increase or decrease by points the number of lines before or after a
paragraph (6 points = 1 line); To change the line spacing within paragraphs, select the drop-
down arrow for the Line Spacing list box, then select one of these options: 1.5 lines, Double,
FACULTY OF ENGINEERING SCIENCES AND TECHNOLOGY

At least, Exactly, or Multiple; If one of the last three options is chosen, enter a number in the
At text box. When finished, choose OK.

Changing Default Tabs


Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
To change default tabs, click on the small arrow in the bottom right of Paragraph portion to
display the dialog box. Click on the Tabs button in the dialog box. In the Tabs dialog box; To
change the default tab stops to a different setting, click in the Default Tab Stops field and enter

the new value, for example enter .25". Tab stops will be set every quarter inch based on these
settings; Click OK to close the dialog box and apply the new tab stops settings to the Ruler.

Inserting Special Characters

To insert special characters, place the insertion point at the point in the paragraph where a symbol
or special character is to be placed; Choose Insert, Symbol to display the Symbol dialog box.
Click the Symbols tab to select a symbol, or click the Special Characters tab to select a special
character; On the Symbols tab, select the font set that contains the symbol to be inserted in the
document in the Font drop-down list box. To view a symbol in the displayed table, click the
symbol. The symbol is then displayed in an enlarged and highlighted view; To insert a symbol or
special character, click the item to be inserted, then click the Insert button. Click the Close button
to close the dialog box and return to the document.

Zooming the Document Display

Zooms customizes the on screen size of the document in a way the user wants to view it.
However, zoom setting does not affect the actual formatting of the document. To adjust
zooming option, click View, Zoom; In the drop-down list, select the zoom percentage to be
used. The document display changes to the zoom percentage selected; If the required zoom
percentage is not in the list, type the percent in the text box part of the Zoom button and press
Enter.

Creating Custom Colors/Gradients/Textures

To create custom colors, right click on the graphic element to be colored. Along with the
shortcut menu appears the Drawing toolbar. Then click the drop-down arrow of the Fill Color
or Line Color button and select More Fill Colors to open the Colors dialog box; Click the
Custom tab at the top of the Colors dialog box. Set desired color. For gradient settings, in the
drop-down arrow beside the Fill Color button, select Gradient at the bottom of the color
palette instead of More Fill Colors. Click the Gradient tab and make desired settings. Texture
tab can also be selected to apply designs to the objects.

Inserting Clip Art/AutoShapes/Pictures/WordArt

To insert a Clip Art/ AutoShape, Picture or WordArt, position the insertion point in the document
where the image is to be appeared. Choose Insert and then the desired option. Related dialog box
appears, then make required selections. The inserted object can be customized in a number of
ways. The user can change colors of the image, edit, reposition and resize them.
There are two ways to rotate or flip the inserted object. One is to right click on the object and
then choose Format Picture/Shape. Then click on the 3-D Rotation button. From here, the
desired rotation in the x, y and z axes may be chosen. The other gives access to that same tool
and to the commands Rotate Left, Rotate Right, Flip Horizontal, and Flip Vertical. To do this,
click the object to be adjusted choose Page Layout, click on Rotate and then choose the
desired option.
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
These commands automatically execute. If Free Rotate is chosen (if we bring the cursor on the
small green circle that appears above any object when we select it, this gives the free rotate
option) continue with the following steps; Move the pointer over the rotate handle and, when it
assumes the shape of the rotate tool icon, hold down the right mouse button; The pointer changes
to four circling arrows. Drag right or left. While dragging, a dotted outline indicates

where the object would be if the mouse button is released; until the object is deselected it can
be continuously rotated, even if the mouse button has been released. Place the pointer over a
circle handle, hold down the mouse button and continue to rotate. Release the mouse button
when the object is rotated to the desired position, and click outside the object to deselect it.

Creating Headers and Footers

Headers and footers contain information repeated at the top or bottom of the pages in a
document. To set Header and Footer, with the document open, choose Insert, then click on
Header or Footer. Choose the desired format from the drop down list. The Header pane is
displayed in the document; Type and format the information for the header; To include the
Page Number, Number of Pages, or current Date or Time, click the corresponding button on
the Header and Footer toolbar; To create a footer, click the Go to Footer Button on the toolbar
and type and format the footer just as was done for the header. Click Close Header & Footer
button to return to the document.

Graphs

To insert a graph, position the insertion point where the chart is to be appeared. Choose Insert,
Chart to open the Insert Chart dialog box. Click on the desired type of chart; Microsoft Graph
opens showing a datasheet with sample data in it. This overlays the Word document which
now displays a graph of that sample data at the insertion point. It is surrounded by a box with
eight handles indicating it is selected. At the same time, the Microsoft Graph Standard and
Formatting toolbars appear at the top of the document window; Click in the cells of the
datasheet or use the Tab key to navigate from cell to cell, entering data to suit the needs. Click
the various buttons in the Microsoft Graph toolbar to change Chart Type, orientation of data
to display By Row or By Column, or format highlighted text. Changes are reflected in the
graph on the document; when satisfied with the data entry and visual choices, click outside
the selection rectangle of the chart in the document to close the datasheet, return to the
document, and deselect the chart; to edit the chart, right click on the chart in the Word
document and choose Edit data. The Microsoft Graph datasheet reopens and can be revised.

Changing the Default Folder

The user can change the default folder used in Word so that when he opens an existing
document or saves a new document, the folder he chooses automatically appears as the
current folder. To do this, choose File, Options; then click on the Save tab; In the Default file
location text box, type the full path name (including the drive letter) for the folder to be used
as the default; then choose OK.

Drawing Tables

Drawing a table allows the user to place the rows and columns where he wants them. To create a
table, click the Tables and Borders button to bring up the Tables and Borders toolbar and
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
change the mouse pointer to a pencil; Drag the mouse pointer from one corner of the new
table to the opposite corner to create the rectangle outline for the table; If a line is to be
removed, click the Eraser button on the Tables and Borders toolbar and drag across the line.
If the user needs the data from a table, he may (rarely) want to convert the table to text with
some sort of separator between the data for the former columns. To do this, select the entire
table by positioning the mouse directly at the left top of the table until the pointer changes to a

four directional arrow and then click it. A Table toolbar appears at the top of the document
window. In the Layout tab, choose Convert to Text. Choose to separate the text with Paragraph

Marks, Tabs, Commas, or type a new character in the other text box; then choose OK.
Similarly the user may want to convert the lines of text into a table. To do this, select the rows
of tabbed text to be converted; Choose Insert, click on Table and then choose Insert Table.

The cells of the table can be edited and formatted, like moving and copying cells, splitting and
merging cells, adjusting row and column spacing/width, inserting and deleting rows and
columns, by selecting appropriate options from the menu that appears on right clicking the
table or the selected cells.

EXERCISES

Write a report of not more than two pages, on different types of computer systems namely
microcomputers, minicomputers, mainframes, super computers. The report should be
properly formatted with appropriate indentations, and font styles with single line spacing
and the specified alignment: 1 cm from left, 1 cm from top. You may use additional styles
like drop cap and columns. Include your name and roll number in the header field. Also,
the total market in 1985 for the products and services of the top 100 companies in the
computing industry is given below as percentages. Present this information in graphical
form.
Microcomputers - 10.18% ; Minicomputers - 11.18% ; Mainframes - 6.8% ; Data
communications - 7.46% ; Peripherals - 27.23% ; Software - 7.63% ;
Services - 5.72% ; Maintenance - 11.56% ; Other - 2.19%

Attach your printed output.


Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 02

OBJECT

Exploring the advanced features of Microsoft Word

WORD PROCESSING CONCEPTS

Paragraphs: Formatting Line and Page Breaks


The user would not want to have one line of a paragraph appear on the bottom or top of a page alone. This is
Widow and Orphan control. Select the paragraph that you want to prevent from breaking onto two pages. On the
Page Layout tab, click the Paragraph Dialog Box Launcher, and then click the Line and Page Breaks tab. Select the
Keep lines together check box. Keep with Next will prevent a page break between the selected paragraph and the
following paragraph. Page Break Before will insert a manual page break before the selected paragraph.
To insert page breaks, position the insertion point anywhere within the paragraph to be formatted, and choose
Insert, and then click on Page Break.

Sections Breaks

Section breaks are important when the user need to apply different formatting choices to different parts of the
document. To insert Section Breaks, position the insertion point where the section break is required, and then
On the Page Layout tab, in the Page Setup group, click Breaks. Click the type of section break that you want to
use. Different options are: Next Page-to start section at the top of the next page in the document; Continuous-to
start section at the insertion point (for varying columns on one page); Even Page-to start section on next even-
numbered page in the document (most often a left-facing page); Odd Page-to start section on next odd-
numbered page in the document (most often a rightfacing page).

Use the Continuous section break to balance columns on a page. Insert the break at the end of a document that
is divided into columns where the last column does not fill to the end of the page.

To remove Section Breaks, press Ctrl+H to issue the Replace command, and then choose the More button to
expand the Find and Replace dialog box; With the insertion point in the Find What text box, choose the Special
button, and then select Section Break at the bottom of the list. Do not put anything in the Replace Wi th text
box; Choose Find Next to find the next section break. The section break is selected behind the dialog box.
Continue searching by choosing the Find Next button, or remove this section break by choosing the Replace
button; If all the section breaks are to be replaced, choose the Replace All button. Word will tell how many
replacements were made; then choose the OK button and Close to return to the document.

Inserting Page Numbers

To insert page numbers, choose Insert, Page Numbers to display the list box, select Bottom of Page (Footer), or Top of
Page (Header) and choose from the given options to align the page number horizontally on the page; in the Header
& Footer Toolbar Select the Different First Page check box if a page number is not to appear on the first page of
the document or there is any other formatting required for the first page; To change format options, choose the
Format Page Number button and select from the options on the Page Number Format dialog box; Choose OK to
return to the Page Numbers dialog box, and then choose OK or Close to return to the document and save and apply
the changes.

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science
Page numbering is continues throughout the entire document. There may be instances where the user need to number
sections differently. For example, he may want to start each section with page 1. For this, divide the document into

sections by inserting section breaks, and then position the insertion point in the section to apply unique numbering.
Choose Insert, Page Numbers, and then choose the Format Page Number button. Make any changes to the options
on the Page Number Format dialog box. To restart numbering for this section, in the Page Numbering section of
the dialog box, click the Start At option and type or select the starting page number. Then choose OK to return to
the document. Like page numbers, Headers and Footers also can be made different for different section.

Page Setup

Changing the default page layout formatting enables the user to choose whether the headers and footers are the
same throughout the document, or change from odd page to even page. To change layout, select the header or
footer to be formatted. This makes a toolbar appear at the top of the document window. Click one of the options:
Different Odd and Even or Different First Page, depending on the needs for the headers and footers in the
document; Select the Header/Footer drop-down arrow to choose between Top, Center, or Justified.
To change margins, choose Page Layout. Click on the Margins drop down arrow, either select or type in the
margins for all sides in Custom Margins, including the From Edge settings for the Header and Footer in the Layout
tab.; If the user will be binding the document and want the inside margin to remain constant, click Mirror Margins
to toggle that feature on and off; In the Apply To box, indicate to what portion of the document these changes are
to be applied; When finished, choose OK. The default measurement units for margins are inches. To change units,
choose File, click Options. Click Advanced tab. In the Display section, change the unit in the show measurement in
units of text box.
Paper size can also be changed. To change paper size, choose Page Layout and click on Size. Select an appropriate
paper size from the drop down list; If the paper measurements are not included in the Paper Size box, type in the
appropriate measurements in the Width and Height text boxes given in the Paper tab in the dialog box when we
click on More paper sizes. In the Apply To box, indicate to what portion of the document these changes are to be
applied; when finished, choose OK.

The Paper Source tab tells the printer where to go to get the first page of a document and then where to go to get all
subsequent pages. To choose paper source, on the same dialog box, select the Paper Source tab; In the First Page
list box, select the location or source for the paper of the first page of each document for the printer; In the Other
Pages list box, select the location or source for the paper of all subsequent pages for the printer; In the Apply To
box, indicate to what portion of the document these changes are to be applied; When finished, choose OK.

Enabling Virus Protection

Macros automate frequently used tasks to save time on keystrokes and mouse actions. Many were created by using
Visual Basic for Applications (VBA) and are written by software developers. However, some macros can pose a
potential security risk. A person with malicious intent, also known as a hacker, can introduce a destructive macro
in a file that can spread a virus on your computer or into your organization's network. To help prevent macros from
corrupting the system, Word provides a feature that checks each document opened for the existence of macros
(some Word viruses are started from macros). When you open a file that has macros, the yellow Message Bar
appears with a shield icon and the Enable Content button. If you know the macro, or macros, are from a reliable
source then on the Message Bar, click Enable Content otherwise disable it.

Creating Bookmarks

A bookmark is a named marker for a block of text, an entire table or a graphic, a cell or range of cells in a table, or
simply a position in a document. First enter a bookmark where it is wanted, then the user can move to it or cite it as
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
a reference in a field or formula. To create a book mark, click in the document at the location where the bookmark is to
be inserted, or select the text or graphic to be named; Choose Insert, Bookmark to display the Bookmark dialog box;
enter the new bookmark name in the Bookmark Name text box. The user can also select an existing bookmark

name from the list, and Word moves the bookmark from its existing location to the place selected; Click the Add
button to add the bookmark to the bookmark list and close the dialog box.

To delete a book mark, choose Insert, Bookmark; Select the name of the bookmark to be deleted from the Bookmark
Name list box; Click the Delete button. The selected bookmark name is removed from the list box and the document;
Click the Close button to close the dialog box and return to the document.

Hyperlinks

The user can create a link that jumps to a document, also called a page, on his computer and on a network or
intranet. Two types of hyperlinks can be created: one that jumps to a bookmark in the same document and another
that jumps to a URL.

First type is for named locations. Named locations can be in the same document the user is working with (an internal
link), or in a different document (an external link). The named location targets a Bookmark inserted at the position to be
jumped to within a document. To do this, use the Insert Hyperlink button on the Standard toolbar to open the Insert
Hyperlink dialog box; choose either Place in this document or Existing File or Webpage button. Locate the Word
document containing the Bookmark this link is to jump to. The user can also jump to a named range in Excel, a database
object, or a specific PowerPoint slide; choose OK to confirm the choice or Cancel to negate it.

Second type is for URLs and other links. For this click the Insert Hyperlink button on the Standard toolbar to
open the Insert Hyperlink dialog box; click on the Browse the Web or Browse for File button to locate and
select the document. The path and document name are automatically entered in the Address text box; choose
OK to confirm the choice or Cancel to negate it.
Mail Merge
If the user is sending many documents, mail merge can save lots of time. The user can design a form that prints
multiple labels on a page similar to the way he designs a form letter.

• Creating Main Document - A main document is a letter, envelope, or other document that has text that the user
wants to appear on every merge, and codes that will be replaced with entries from a data source of names and
addresses.
To create the main document, open a new blank document window. Then choose Mailings, Mail Merge. In the
drop down list select the Step by step Mail Merge Wizard to display the Mail Merge Helper. Select the
document type under Step 1; then select the starting document.
The wizard now asks to select recipients (data source-a location for names and addresses). Now there are two
ways to get the data source. Either select from existing data sources or create a new list.

• Opening an Existing List - The existing data source could be a Word document, an Excel document, an Access
database or query, a dBase file, or even a FoxPro file, as well as many others. For this, select the Use an
existing list option and then browse. Word can read many different data source formats. Choose the drop-down
arrow on the Files of Type list to select the file type for the data source; Navigate in the Look In list to find the
drive and folder where the data source file is stored. Select the file and choose Open, or if available, click the
MS Query button if a non-Word database is to be selected.

• Creating a New List - If the user does not have a data source that contains list of names and addresses for the
merge document, one can be created using the Type new list option and then click on Create. The New Address
15
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
List dialog box is displayed; Scroll through the list of fields in the Field Names in Header Row list box to see
commonly used field names provided by Word; Edit the list of field names using the Customize Fields button.
The top-to-bottom order of the fields is the order the fields will be in for data entry in the data source. When

• finished, choose OK; Word displays the Save As dialog box. In the File Name box, enter a name for the data
source document and choose Save.

• Inserting Fields - Step four is to write the letter. The wizard helps to insert fields. Merge fields are the variable
information that changes for each document. Position the insertion point where a merge field is to be appeared
and then select the field from the list presented; Type any text or punctuation that is needed in the document
and continue inserting merge fields where necessary.

EXERCISES
• Create a word document, using mail merge wizard, which produces individual information reports for a list of
students in the form of a table, including their first name, last name, father’s name, home address, phone
number, email addresses, and home page address as hyperlinks (if any). Enter few sample records. Table
should be properly formatted.
Remember to include your name and roll number in the header field. Get a printout to be attached here, of the
page that contains only field name and not any records. Also attach 1 sample report containing actual data.
Attach the printed output.
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 03

OBJECT

Working with Microsoft Excel

WORKING WITH SPREADSHEETS

Name Formula
Box Bar

Status
Bar

Figure 7.1: Excel Home window


Entering Text

Text entries can include a combination of alphabetic characters, numbers, and symbols. By
defaults, when text is entered in a cell, the text automatically aligns on the left side of the cell. Occasionally, a number
may be entered as a text entry. To make Excel accept numbers as text, type an apostrophe (') followed by the number.

Entering Numbers

Numbers are constant values containing only the following characters: 0 1 2 3 4 5 6 7 8 9 + - (


) , / $ % . E e. User can enter integers, such as 24 or 973; decimal fractions, such as 908.37 or 0.72; integer
fractions, such as 3 1/4 or 2/3; or scientific notation, such as 5.87137E+3. (See also "Entering: Text" and
"Entering: Dates and Times.") . By default, the numbers automatically aligns on the right side of the cell.

To enter a fraction, type an integer, followed by a space, and then the fraction. If only the fractional part is to be
entered, type a zero, a space, and then the fraction; otherwise Excel may interpret the entry as a date.
Entering Data in a Selected Range

To speed data entry, one can preselect the range in which data is entered. Then, the active cell will move
automatically to another cell in the range after a specified key is pressed.
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

To enter data in selected range, select the range in which data is to be entered. The first cell in the selected range is
active and appears with a white background; Type the data to be entered in the first cell; Press Enter to move down
one cell, press Shift+Enter to move up one cell, press Tab to move right one cell, or press Shift+Tab to move left
one cell.

Entering Data Series

Excel includes a feature named AutoFill, which enables the user to enter sequences of values automatically.
AutoFill can be used for dates, months, years, positive and negative numbers, certain sequences such as Qtr 1, Qtr
2, and so on.

To fill a range with a sequence of numbers, enter the numbers in the first two cells of the range. (These two cells
can be in the same column or the same row.) ; Select the two cells, then position the mouse pointer over the handle
in the lower-right corner of the selected range; the pointer changes to a cross; Drag the cross to the end of the range
to be filled with the sequence and release the mouse button; AutoFill completes the sequence of numbers.

Entering Dates and Times

To quickly enter the current date in a cell, select the cell and press Ctrl+; (semicolon). To enter the current time in a
cell, press Ctrl+: (colon). The date and time can be combined in a single cell by separating the date and time with a
space.

To manually enter a date or time, enter the date into the cell using any of these formats: 11/6/97, 6-Nov-97, 6-Nov,
Nov-97; or, enter the time into the cell using any of these formats: 21:41, 21:41:35, and 9:41 PM, 9:41:35 PM. For
any other styles, Excel will format the number using one of the formats listed above. If Excel does not recognize
the entry as a valid date or time format, the entry is treated as text and, in an unformatted cell, aligns it to the left.

Selecting Multiple Ranges/Worksheets


While working in Excel, more than one range of data can also be selected. Instead of selecting ranges individually
and formatting them, all ranges can be formatted at once.

To select multiple ranges, select the first range of cells; Hold down the Ctrl key; then click and drag to select the
next range of cells; Repeat Step 2 until all the desired ranges are selected.

Complete Worksheet(s) can also be selected, if the user wants to group the worksheets and perform actions on all
selected worksheets.

To select a worksheet in the current workbook, click the sheet tab. The worksheet displays; If all cells are to be
selected in the current worksheet, click the rectangle that appears at top left corner, at the intersection of the row
headers and column headers; To select multiple Worksheets, hold down the Ctrl key; then repeat the above steps.

Hiding Gridlines/ Row and Column Headings

The user can hide the worksheet gridlines (and other screen elements) to make the display appear less like a
spreadsheet and more like a graphic or paper display. Hiding the on-screen gridlines also gives a better appearance
to data-entry forms and on-screen reports.

To turn the worksheet gridlines off, choose Page Layout, clear the Gridlines check box.

There are other parts of the Excel worksheet that can be hidden from view. These options appear on the Page
Layout tab.

Hiding Worksheets/Workbooks

The user may want to hide a worksheet in a shared workbook so that others will not see the worksheet.

To hide a Worksheet, right click the on sheet tab for the worksheet to be hidden; Choose Hide. To restore the
worksheet, right click the on any sheet tab, choose Unhide. In the Unhide dialog box, select the name of the
worksheet to be displayed; then click OK.

To hide a Workbook, the mouse pointer in the workbook to be hidden, choose View, Hide. To restore the workbook,
choose View, Unhide. In the Unhide dialog box, select the name of the workbook to be displayed; then click OK.

Hiding Columns and Rows

The user can hide columns/rows temporarily so that they do not print or appear on-screen. Hiding columns or rows
doesn't affect the results of formulas that refer to hidden cells. To hide column/row, right-click the column heading
of the column to be hidden, or right-click the row heading of the row to be hidden; from the shortcut menu, choose
Hide.

Windows Freezing Worksheet Panes

Excel enables the user to freeze the window pane at selected rows and columns so that they remain on-screen as he
scrolls through large worksheets. To freeze Worksheet panes, position the cell pointer at the intersection of the row
and column that is to be remained on-screen while moving through the worksheet; Choose View, Freeze Panes. To
unfreeze the window pane, choose View, Freeze Panes, and Unfreeze Panes.

Inserting and Deleting Columns/Rows

As the user edits worksheet, he may need to insert or delete entire columns/rows in the worksheet. If a column/row
is to be inserted, select the column/row header of the column/row to be move to the right when the new
column/row is inserted; or, if deleting a column/row, select the column/row header of the column/row to be
deleted; To insert a column, on the Home tab, choose Insert, Insert Sheet Columns/Insert Sheet Rows; or, to delete
the selected column/row, choose Delete.

Inserting Worksheets

New worksheets can be easily inserted (as many as 255 total) at any time. To insert a
Worksheet, open the workbook to which a new worksheet is to be added; Choose Insert, Sheet. The new worksheet
is inserted just before the current worksheet; Drag the sheet tab of the new worksheet to where the worksheet is to
be appeared.

The default number of worksheets that appears in a new workbook can also be changed. Choose File, Options; then
click the General tab. In the Include this many sheets text box, type the number of worksheets to be contained in
new workbooks; then click OK.
Naming Worksheets

The user can also assign his descriptive name of up to 31 characters to each worksheet. The characters / \ : ? * [ ] <
> cannot be used in the names. To name a Worksheet, double-click the sheet tab for the worksheet to be renamed;
Type the new name for the worksheet and press Enter.

Protecting Cell Data/Worksheets

If the user needs to share worksheets with other users, he can prevent the contents of specific cells from being
changed by turning on worksheet protection. The user first must unlock cells that he wants others to be able to
change, and then protect the entire worksheet.

To protect cell data, select the range of cells to be unlocked. These are the cells that can be modified by other users.
No selection is made if whole Worksheet is to be protected; Choose Review, Protect Sheet. Select the desired
options describing what is to be protected in the current worksheet. A password can also be assigned so that only
users with access to the password can make changes to the unlocked cells by typing the password in the Password
text box; then click OK.

To turn off worksheet (and therefore cell data) protection, choose Review, Unprotect Sheet Protecting Workbooks
A user can prevent other users from accessing or changing the contents of a workbook by assigning password
protection to a file.

To protect a Workbook, open the workbook to be protected; then choose File, Save As, and click the Tools button;
In the General Options dialog box, enter the passwords –the user can set one to open the workbook and another to
modify the workbook. Passwords are case sensitive; Reenter the password(s) in the confirmation box(es); then
click OK; Select Read Only Recommended if the workbook is to be opened as Read-only (they must save the
workbook with a different name if they want to save their changes--they cannot make any changes to the existing
workbook); then click OK; Click the Save button to save the workbook with changes.

To remove protection from a workbook, open the workbook and choose File, Save As; then click the Tools button;
In the General Options dialog box, remove the passwords from the text boxes (and clear the Read-Only
Recommended check box, if applicable), and click OK. Then click Save to save the workbook with these changes.

Rotating Text

In Excel, the default orientation for text is horizontal, reading left to right. Text can also be rotated to any direction.
This can be used for vertical titles for reports or to label the sides of charts, tables, or drawings.
To rotate text, select the cell or range containing data to be rotated. Choose Format, Cells; then click the Alignment
tab; In the Orientation area, drag the pointer in the second box up or down to change the orientation of the text (as
displayed in the Orientation preview box); or, specify a value in the Degrees box between 90 and -90 degrees.
Then click OK. Or, select the cell or range containing data to be rotated. In the Home tab, Alignment portion,
choose the Orientation button. Select the desired option.

Shrinking Text to fit in a Cell

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science
If the user needs to fit text in a cell without widening the column containing the text, he can shrink the size of the
text by using the Shrink to fit alignment option.
Select the cell or range containing data to be shrunk and right click on it. Choose Format, then click the Alignment
tab; Select the Shrink to Fit option; then click OK.

Wrapping Text in a Cell

For long text entry in a cell, Excel can wrap the text so that it forms a paragraph that fits inside that cell by
increasing cell's height to accommodate multiple lines of text. Select the cell or range containing data to be
wrapped. Choose Format, then click the Alignment tab; Select the Wrap Text option; then click OK.

Entering Formulas

Formulas enable the user to perform calculations by using values in the worksheet. Arithmetic operators that can be
used in formulas include + for addition, - for subtraction, * for multiplication, / for division, % for percentage, and
^ for exponentiation. For example: =a1+b1 adds the contents of a1 and b1 in the cell where the formula is typed.

To fill the same formula in multiple cells, select the adjacent cells or ranges to be filled; With the range(s) still
selected, type the formula or value in the active cell; Press Ctrl+Enter (rather than just Enter) to enter the formula
or value.

To reference cells in other Worksheets, select the cell where the formula is to be appeared , and type an equal sign
(=) to start the formula; Click the sheet tab containing the cell to be referenced in the formula; Select the cell or
range to be referred to. The complete reference appears in the formula bar; Finish the rest of the formula; then
press Enter to complete the formula.
Excel also provides functions like SUM, AVERAGE, etc. Select the cell where the function is to be appeared, and
type an equal sign (=) to start the function; Type the function name (such as SUM, AVERAGE, etc) and a left
parenthesis; Select the range of cells for the argument and press Enter. Excel automatically adds the closing
parenthesis and enters the function. References to columns or rows can also be entered manually, using comas (,)
for separation. If colon (:) is used between two references then, it acts as range operator, which produces one
reference to all the cells between two references, including the two reference. Following are some of the most
commonly used formula.

- SUM: Adds all the numbers in a range of cells. Syntax: = SUM(number1, number2, …..)

- AVERAGE: Returns the average (arithmetic mean) of the arguments. Syntax: =AVERAGE(number1, number2,
…..)

- COUNT: Counts the number of cells that contain numbers and numbers within the list of arguments.
Syntax: =COUNT(value1, value2, …..)

- COUNTA: Counts the number of cells that are not empty and the values within the list of arguments.
Syntax: =COUNTA(value1, value2, …..)

- PRODUCT: Multiplies all the numbers given as arguments and returns the product. Syntax:
=PRODUCT(number1, number2, …..)
- SUMIF: Adds the cells specified by a given criteria.
Syntax: SUMIF(range, criteria, sum_range)
Where ‘Range’ is the range of cells to be evaluated according to the given criteria. ‘Criteria’ is the criteria in the
form of a number, expression, or text that defines which cells will be added. ‘Sum_range’ are the actual cells to
sum. The cells in sum_range are summed only if their corresponding cells in range match the criteria. If
sum_range is omitted, the cells in range are summed.

For example: Suppose B1:B4 contain the values 100, 200, 300, and 400 respectively.
C1:C4 contains 1, 4, 6, and 2 respectively. Now the expression SUMIF(B1:B4,">275",C1:C4) will add 6 and 2
as there corresponding values in cells B3 and B4 are greater than
275. Hence the result will be 8. If sum_range argument is omitted then the result becomes 700.

- FACT: gives factorial of a number


Syntax: FACT(num)

- Large: returns kth largest value


Syntax: Large (Array, K)

- SMALL: returns kth smallest value Syntax: small(array, k)

- Ceiling: returns nearest kth value integer

Formulas: Absolute, Relative, and Mixed Cell References

When a cell contains a formula with references to other cells, several methods can be used to handle those references.

Excel normally uses relative references for cell addresses in a formula, unless specified otherwise. When relative
references are used, the cell references in a formula automatically adjust after the formula is copied to another cell
or range. If cell B10 contains the formula =SUM(B3:B9), for example, and user copies this formula from cell B10
to cell C10, the new formula in cell C10 automatically adjusts to read =SUM(C3:C9).

To prevent a cell reference in a formula from changing when that formula is copied to another cell or range, use an
absolute reference. Absolute references can be indicated by typing a dollar sign ($) in front of the column letter and
the row number. In a sales worksheet, for example, if the user have a column of formulas that multiply a value by
the commission percentage located in cell D7, he could use $D$7 to refer to that percentage in the first cell; then
copy the formula down the column.

Combinations of these two types of references called mixed references can also be used. For example $C3 prevents
the column from changing, C$3 adjusts the column to a new location but the row remains fixed when the formula
is copied.

To use this, place the cell pointer in the cell where the formula is to be entered; To enter an absolute or mixed
reference in a formula, type an equal sign (=) to start the formula (to enter a relative reference, just type the
reference--no special treatment is needed). Then type or click the cell reference; Press F4 until the desired
combination of dollar signs appears, and then type the arithmetic operator, such as a plus sign (+); Continue to type
other values or cell references and operators as needed; then press Enter to complete the formula.

Creating a Text String

At times, the user may need to create a formula that joins the contents of two cells. Excel refers to this action as
concatenation.
For example: If a worksheet includes first names in column B3 and last names in column C3, the user can enter a
formula in a third column that joins the first name with the last name: =B3&" "&C3 where ampersand (&) is the
concatenation operator and (" ") simply indicates a space between the two text strings.
Displaying Formula Instead of Results

From anywhere in the worksheet, choose Formulas, click the Show Formulas button.

To display the results again, choose Formulas, click the Show Formulas button again. Press Ctrl+ ' (the grave
accent, usually located on the same key as the tilde character) to toggle between viewing results and formulas.

Auto Calculate

Select the range to be summed. The Calculate button in the status bar automatically displays the sum of the
selected range (or right click the AutoCalculate button to see more functions); Right-click the AutoCalculate button
in the status bar; From the pop-up menu that appears, select the function to be used, such as Average or Count. The
result of the function selected appears in the status bar.

Logical Functions

The logical functions enable the user to add decision-making and logical tests to the worksheets. The IF statement
is useful for testing conditions and making decisions based on a cell's contents. The AND and OR functions can
test multiple criteria or test conditions for use in IF functions. The following examples show the use:
• =AND(D15,G23<30)result is TRUE only when D15 is not zero and G23 is less than 30
• =IF(AND(D17>10,D17<30),"Valid","Invalid") returns Valid if the contents of cell D17 is greater than
10 and less than 30; otherwise the formula returns Invalid
• =IF(NOT(OR(D17=10,D17=30)),"Not 10 or 30","Contains 10 or 30") tests whether cell D17 contains
the result 10 or 30 and produces the message Not 10 or 30 when the cell does not contain either of those results;
otherwise, the formula result is Contains 10 or 30
• =IF(OR(D17=10,D17=30),"Contains 10 or 30","Not 10 or 30") tests whether cell D17 contains the
result 10 or 30 and produces the message Contains 10 or 30 when it does; otherwise, the formula produces
the message Not 10 or 30

Math and Trigonometric Functions

Like logical functions, math and trigonometric functions can also be used in the Worksheets. Trigonometric
functions use angles measured in radians. Following are some examples:
• =ABS(A10)returns 18 when cell A10 contains -18
• =ACOS(0.5)returns 1.047198 (radians)
• =DEGREES(0.5) returns 28.64789 (degrees)
• =LOG(12,3) returns 2.26186 =ROUND(102.927,2) returns 102.93

Statistical Functions

Similarly, statistical functions can als0 be used in the Worksheets. For example:
• =COUNTIF(B1:B4,">100") returns 1 if the range B1:B4 contains the numbers 57, 102, 84, and 98

• =MEDIAN(1,4,2,6,9) returns 4
• =MEDIAN(1,4,2,6,9,10) returns 5 (average of the two middle values, 4 and 6)

PRINT TITLES
  
Page layout Print titles Rows to repeat at top $1:$n
EXERCISES

1. Design a TEMPERATURE CONVERTER from Celsius to Fahrenheit and Fahrenheit to Celsius. Present the
Converter with appropriate design. Formulas for conversion are as follows:
[°C] = ([°F] − 32) · 5/9 [°F] = [°C] · 9/5 + 32
Also report the weather conditions as HOT if the temperature exceeds 35°C, WARM if the temperature is between 20°C to
35°C and COLD if the entered temperature is below 20°C.

2. Draw the sine ( sin ) and cosine ( cos ) wave on a single graph and format the graph accordingly. Take from 0
to 360 with the interval of 15 . Also Compare the values of sin and cos and tell at which angle these values are equal.
Attach the printed output.
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 04
OBJECT

Familiarization with the environment of Microsoft Power Point.

USING POWER POINT

A user can communicate information better and more easily with a PowerPoint presentation. A presentation is a
series of slides that a user creates by using PowerPoint. The more important the message, the clearer the
presentation should be. Also for larger audience, the message must be easy to grasp.

The facilities PowerPoint provides are discussed below:

Creating a New Power Point Presentation

Presentation Type: Open Power Point and you will be prompted by a dialog box with different choices. These
choices are explained below. If Power Point is already open or this box does not appear, select File|New from the
menu bar.
• Blank Presentation:Select Blank Presentation to build the presentation from scratch with no preset graphics or
formatting.
• Recent Templates: This option shows all the templates used previously during the current session of your work.
• Sample Templates: This option provides templates and ideas for a variety of presentation types. Page through
the wizard to select the required type.
• Themes: Power Point provides many templates with different backgrounds and text formatting to begin your
presentation. Preview each design by highlighting the template name in the menu. Double click on the chosen
design to open the required template.
• My Template: This option allows you to insert and/or create your own design template.
• New from Existing: This option lets you convert the older version power point files into the current version.
Then you can save it with the new format by using the File|Save option from the menu bar.
To open an existing Power Point presentation, select File|Open option from the menu bar. Select the folder in
which the file is located from the Look in: drop-down menu and highlight the file on the list. Click Open to open
the presentation.

Screen Layout Views

Power Point gives you three screen layouts for constructing or viewing your presentation. These can be selected by
using the icons given in the bottom right corner, or you can go to the View menu and select these options from the
Presentation View section.
normal slide show

slide sorter Figure 3.1 Screen Vie


Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

• Normal View: This screen is split into three sections showing the presentation window on the left, the slide
in the main window, and notes at the bottom. The presentation window can further be viewed in two different
ways:
• Outline View: he presentation outline is displayed on the majority of the screen with small windows for the
slide and notes. This view is recommended for editing text.
• Slide View: The slide view displays each slide on the screen and is helpful for adding images, formatting
text, and adding background styles.
• Slides Sorter View: A small image of each slide is displayed In Slide Sorter View. Slides can easily be
ordered and sorted from this screen.

menu bar

slide window
presentation
window

notes window
status bar

screen views

Figure 8.2: The Power Point screen layout in Normal View


Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Click the Slide Show button to view the full-screen slide show.

Working with Slides

Insert a New Slide :In the Normal View, select the slide you want the new slide to appear after
by clicking the slide's number. Select Home| NewSlide from the menu bar. Choose the page
layout from the window.

Applying a Design Template: To add a design template or change the existing one, select Design
menu, and choose the template from the given options in the Themes section. If you want to
change the design of only one slide, then right click on the chosen theme and select ‘Apply to
Selected Slide’ option.

Changing Slide Layouts: To change the layout template of the slide, select Home| Layout from
the menu bar. Select one of the layout thumbnail images.

Reordering Slides: To reorder a slide in Slide Sorter View, simply click on the slide you wish to
move and drag it
to the new location. In Normal or Outline View, click the slide icon beside the number of the
slide you want to move and drag the icon to a new location.
Hide Slides: If you do not want a slide to appear during the slide show, but do not want to delete
the slide as it may be used later, the slide can be hidden by selecting SlideShow|HideSlide from
the menu bar. To add the slide back to the slide show, select SlideShow|HideSlide again.

Create a Custom Slide Show: The Custom Slide Show feature allows you to select the slides you
want to display in the slide show if not all the slides should be used. For this, select Slide Show|
Custom Slide Show|Custom Shows menu bar; Click the New... button in the Custom Shows
window; In the Define Custom Show window, type a name for the slide in the Slide show name
field; Add slides to the custom show by highlighting them in the Slides in presentation window
and clicking the Add>> button. Those slides will then appear in the Slides in custom show
window; To remove slides from the custom show, highlight their names in the Slides in custom
show window and click the Remove button; To reorder slides in the custom show, highlight the
slide that should be moved and click the up and down arrows to change its order in the show;
Click OK when finished; Click the Show button on the Custom Shows window to preview the
custom slide show and click Close to exit.

Edit a Custom Slide Show: Select Slide Show|Custom Slide Show|Custom Shows from the menu
bar and then choose the custom show that needs to be edited from the window that appears on
screen. To edit, click on the Edit... button; to delete a show, highlight the name and click
Remove; to create a copy of a show, click the Copy button. The copy can then be renamed by
clicking the Edit... button; Click the Show button to preview the custom slide show and click
Close to exit.

Adding Contents
Bulleted Lists on Design Templates: Bulleted lists allow you to clearly display the main points
of your presentation on slides. The text boxes on design templates already include bulleted lists.
Click the place holder on the slide to begin adding text and press the ENTER key to return to the
next line and add a new bulleted item. To go to the next line without adding another bullet, hold
down the SHIFT key while pressing ENTER.

Additional Bulleted List: In slide view, create a text box by selecting Insert|Text Box from the menu bar. Then
draw the text box on the slide by holding down the left mouse button while you move the mouse until the box is
the size you want it. Select the Bullets icon from the Home menu to insert new bullets in the text box. In order to
change the formatting of bullets, click on the arrow besides the Bullets icon and select the Bullets and Numbering…
option. This

opens a new window, from where you can change the size and color of the bullets. You can also click the Picture
button to view the Picture Bullet window. Select one of the bullets and click OK.
-OR-
Click the Customize button to select any character from the fonts on the computer. Select a symbol font such as
Wingdings or Webdings from the Bullets from drop-down menu for the best selection of icons. Click on the
characters in the grid to see them larger. Click OK when you have chosen the bullet you want to use. Click OK on
the Bullets and Numbering window and use the same methods described in the "Bulleted Lists on Design
Templates" to enter text into the bulleted list.

Bulleted Lists and New Slides from an Outline: In Normal or Outline view, text can easily be entered in the
outline window and new slides are automatically added. Next to the Slide 1 icon, type the title of the slide. The
text you type beside the slide icons will be the large-type titles on each slide. Press ENTER to type the next line.
This will automatically create a new slide. To create a bulleted list for the first slide, press the TAB key or click
the demote button on the More Buttons menu accessible by clicking the "triple arrow" button at the end of the
formatting toolbar .
-OR-
Press ALT+SHIFT+Right Arrow to demote the selection to a bulleted list item; Continue entering text for the
bulleted list, pressing ENTER at the end of each line to create a new bullet; Create a multilevel list by executing
the demote action again to create a bulleted sub list. Press the promote button on the More Buttons menu or press
ALT+SHIFT+Left Arrow to return to the original list; Create a new slide by executing the promote action until a
new slide icon appears; Continue creating new slides and bulleted lists by using the demote and promote actions
until the presentation is completed. Use the formatting instructions below to format the lists.
If there is more than one bulleted list on the slide, the lists will be designated by numbers enclosed in black boxes.
The example below shows the slide created from the outline on the left. The bulleted list on the left side of the
slide is labeled list "1" on the outline and the list on the right is labeled list “2”. When typing the outline, begin in
the tying new list by pressing CTRL + ENTER. In this example, CRTL + ENTER was pressed after typing
“Access”.

Adding Notes: From Normal View, notes can be added to the slide. These notes will not be seen on your
presentation, but they can be printed out on paper along with the slide. This can be done by selecting File/Print
menu, then under the Settings, in the second drop down menu, select the option ‘Notes Pages’.

Video: To add a video to your presentation select Insert|Video|Video from File or to insert a video from
Microsoft's gallery choose Insert|Video|Clip Art Video. Select the video file and click OK.
Audio: To add sound to your presentation, select Insert|Audio|Audio from File or Clip Art Audio. Select a sound
file and click OK.

Graphics The Drawing Toolbar provides many commands for creating and editing graphics. Select Insert menu
to choose the different tools as explained below:
Adding Clip Art: Select Insert|Clip Art from the menu bar, and use various options to insert, preview and edit the
clips.

Adding Picture or Photo Album: To add a photo or graphic from a file, select Insert|Picture from the menu bar.
Choose the file and insert it. Similarly, in order to insert a complete interactive photo album to the slide, select
Insert|Photo Album option.

Adding Shapes: The Shapes menu allows you to add a number of geometrical shapes, arrows, flow chart
elements, stars, and other graphics on a slide. Select Insert|Shapes from the menu bar, and choose one of the
different shapes provided in the drop down menu.

Adding Action Buttons: Use the action button toolbar to add functioning buttons to slides in a presentation. Select
Insert|Shape from the menu bar and choose the Action Buttons given in the menu. As soon as the button is placed
on the slide, the Action Settings window will appear on screen. Set the actions under either the Mouse Click or
Mouse Over tabs. Actions specified for Mouse Click will execute when the button is clicked on the slide while
actions for Mouse Over will occur when the mouse pointer hovers over the button. Select an action for the button
by choosing a Hyperlink to destination. If you want a sound to be played when the button is clicked, check the
Play sound box and choose a sound from the drop-down menu. Click OK when finished. If the window does not
appear, first click on the action button to select it. Then select Insert|Actions option to open the Action Settings
window. The button on the slide can be resized using the white box handles and the depth of the button can be
changed by dragging the yellow diamond.

Adding WordArt: Add headlines in striking colors and shapes to your presentation using Word Art.Select Insert|
WordArt from the menu bar to choose a Word Art style from the listing.

Adding Charts: A graph or a chart can be used in a presentation to highlight its activity. Select Insert|Chart from
the menu bar. A window appears with different types of charts available in the software. Select any one, and click
OK. A spreadsheet opens up, which lets you edit the values and range of the chart as per user requirement.

Adding SmartArt: SmartArt Graphics include different types of lists, cycles, hierarchies, relationships, etc. that
may be useful in a technical presentation. Select Insert|SmartArt from the menu bar, and then choose the required
options from the window.

Slide Animation: Several animations for slide objects are available through Animation menu on the menu bar.
First, select the text box or graphic that will be animated. Select one of the options from the ‘Animations’ section.
To select a different animation or turn the animation off, select the appropriate choice from the same menu. You
can also change the duration of your animation by specifying the number of seconds in the ‘Duration’ box. The
‘Delay’ option can be used to delay or stop your animation from appearing for the specified number of seconds.

Slide Transitions: Select Transition tab from the menu bar. From the ‘Transition to This Slide’ section, choose a
transition and notice the preview after the transition is selected. The speed or duration of transition can be
changed by entering the time value in the ‘Duration’ box. You can check the "On mouse click" checkbox for the
slide transition to occur by clicking the mouse or using keystrokes, or check the "After:" checkbox and a number
of seconds if the transition should occur automatically. Select a Sound if necessary and check the Loop until next
sound if it should keep repeating until the next sound is played. Click Apply to All if the transition effects should
be added to every slide or Apply if the effects should be added only to the current slide.

Master Slides
Slide Master: Change the style of all slides in the presentation by changing the properties on the Slide Master. Each
Design Template has its own Slide Master that can be altered. If you create slides from scratch, a consistent style can
be added to the presentation by formatting the Slide Master. Select View|Slide Master from the menu bar. Format the
master slide just as you would format a regular slide by formatting text, formatting lists, adding background

patterns and effects, and setting footers. Click the Close Master View button on menu to quit editing the master
slide and return to the presentation.

Headers and Footers: Add the date and time, slide numbers, and other footer text to the master slide from the
Header and Footer window. Select Insert|Header and Foote from the menu bar. Check the Date and time box to
add this feature to the slide. Select Update automatically to always display the current date and time or click
Fixed and enter a date that will not change in the text field provided. Check the Slide number box to add this
feature to the slides. Click the Footer box and add other text to the footer area of the slide. Check the Don't show
on title slide box to hide these features on the title slide of the presentation. Click the Notes and Handouts tab to
make the same changes to notes and handouts pages. Click Apply to All to add the changes to every slide or Apply
to add only to the current slide.

Slide Numbers: To add the slide numbers in a fixed position on the slide, use the Header and Footer window
detailed above. The slide number can otherwise be added anywhere on the slide by placing the cursor where the
slide number should appear and selecting Insert|SlideNumber from the menu bar. The text of the slide number can
the formatting just as regular text style is changed.

Date and Time: A date and/or time can also be added using the Header and Footer window or anywhere else on
the slide. Place the cursor where the date and time should appear on the slide and select Insert|Date and Time
from the menu bar. Select a format from the Available formats box and click Update automatically if this feature
should always be updated to reflect the current date and time. Click OK to finish.

Presentation Basics

 Begin the slide show by clicking the Slide Show button on the bottom of the screen.
 Move to the next slide by pressing the SPACE BAR, ENTER, PAGE DOWN, or right arrow keys or by clicking
the left mouse button.
 Go back to the previous slide by pressing BACKSPACE, PAGE UP, or the left arrow key.
 To end the slideshow before it is complete press ESC on the keyboard.
 A pen tool is available for drawing on the screen with the mouse. Press CTRL+P or click the right mouse button
at any time and a popup window will appear. Choose Pen and the pointer will change to a pen that allows you
to draw freehand on the screen using the mouse. Press the E key to erase all pen strokes. Press CTRL+A to
disable the pen feature and revert the pen back to a pointer arrow.
 If you would like to use the pen to draw on a blank screen during a presentation, press the B or W keys, or select
Screen/Black Screen from the popup menu and the screen will turn black. Press B or W again or choose Next
from the popup menu to return to the presentation when you are finished drawing.
 To hide the pointer and button from the screen press the A key.
 Be sure to preview the slide show using a projector if one will be used during the presentation. Words or
graphics that are close to the edge of the screen may be cut off by the projector.

EXERCISES

Create a Power Point presentation for the report prepared in Lab Choose any topic you want, of not more than
8 slides. Use All the options that we have learned in Lab.
Attach the printed output
Lab Session 06

OBJECT

Creating databases using Microsoft Access

USING MICROSOFT ACCESS

FAMILIARIZATION WITH SOME BASIC DATABASE RELATED TERMS

15. A record in a row on a datasheet and is a set of values defined by fields. In a mailing list table, each record
would contain the data for one person as specified by the intersecting fields.

GETTING STARTED

After opening Access, you will be presented with two major options as shown in figure above. First
if you are creating a new database or the second if you want to open and edit an existing database.
Details about both of these choices are given below:
Figure 9.1 MS Access Welcome window

Open an existing database

If the database was opened recently on the computer, it will be listed in the File Menu either directly or
inside recent option. Highlight the database name and click OK. Otherwise, click Open (Ctrl + O) from File
Menu, navigate to proper folder location, highlight the database name in the listing and click OK.
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Creating a new database

Click New (Ctrl + N) option inside the File Menu. You will be presented with MS Access available
database templates both offline and online and then you are required to select any one of them to
create your new database. Some of the example offline database templates include Blank Database,
Blank Web database, sample database etc. Some of the example online database templates include
Assets, Contacts, Issues and Tasks etc. Unlike Word documents, Excel worksheets, and Power
Point presentations, you must save an Access database before you start working on it. After
selecting "Blank Access database" for example, you will first be prompted to specify a location and
name for the database.

SCREEN LAYOUTS

Database Window

The Database Window (figure 9.2) organizes all of the objects in the database e.g. Tables, Queries,
Forms etc. The default table listing provides links for creating or modifying tables and will list all of
the tables in the database when they have been added.

Design View

Design View (Figure 9.3) customizes the fields in the database so that data can be entered.

Datasheet View

The datasheet view (Figure 9.4) allows you to enter data into the database.

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science
Figure 9.2: Database Window

Figure 9.3: Design View


Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Figure 9.4 Datasheet View .

CREATING TABLES

Tables are grids that store information in a database similar to the way an excel work sheet store information in a
workbook. To create a table click create from main menu. Access provides two ways to create a table from which
there icons table and table design. Double-click on any icon to create a table.

• Create table by entering data will give you a blank datasheet with just ID field and the rest with unlabeled
columns that looks much like an Excel worksheet. Enter data into the cells and click the Save button. After
the table is saved, the empty cells of the datasheet are trimmed. The fields are given generic names such as
"Field1", "Field2", etc. To rename them with more descriptive titles that reflect the content of the fields,
change the view to Design view again and modify names as per requirements.

Create a Table in Design View

Design View will allow you to define the fields in the table before adding any data to the datasheet. The
window is divided into two parts: a top pane for entering the field name, data type, and an option description
of the field, and a bottom pane for specifying field properties as shown in (figure 9.3)

• Field Name - This is the name of the field and should represent the contents of the field such as "Name",
"Address", "Final Grade", etc. The name cannot exceed 64 characters in length and may include spaces.
• Data Type is the type of value that will be entered into the fields. o Text - The default type, text type
allows any combination of letters and numbers up to a maximum of 255 characters per field record.
oMemo - A text type that stores up to 64,000 characters.
oNumber - Any number can be stored.
oDate/Time - A date, time, or combination of both.
oCurrency - Monetary values that can be set up to automatically include a dollar sign ($) and correct
decimal and comma positions.
o AutoNumber - When a new record is created, Access will automatically assign a unique integer to the
record in this field. From the General options, select Increment if the numbers should be assigned in order
or random if any random number should be chosen. Since every record in a datasheet must include at least
one field that distinguishes it from all others, this is a useful data type to use if the existing data will not
produce such values.
oYes/No - Use this option for True/False, Yes/No, On/Off, or other values that must be only one of two.

o OLE Object - An OLE (Object Linking and Embedding) object is a sound, picture, or other object
such as a Word document or Excel spreadsheet that is created in another program. Use this data type to 35
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
embed an OLE object or link to the object in the database. o Hyperlink - A hyperlink will link to an
Internet or Intranet site, or another location in the database. The data consists of up to four parts each
separated by the pound sign (#): DisplayText#Address#SubAddress#ScreenTip. The Address is the only
required part of the string. Examples:
Internet hyperlink example: FGCU Home Page#http://www.fgcu.edu# Database
link
example: #c:\My Documents\database.mdb#MyTable

• Description (optional) - Enter a brief description of what the contents of the field are.
• Field Properties - Select any pertinent properties for the field from the bottom pane.

Field Properties

Properties for each field are set from the bottom pane of the Design View window.

 Field Size is used to set the number of characters needed in a text or number field. The default field size
for the text type is 50 characters. If the records in the field will only have two or three characters, you can
change the size of the field to save disk space or prevent entry errors by limiting the number of characters
allowed. Likewise, if the field will require more than 50 characters, enter a number up to 255. The field
size is set in exact characters for Text type, but options are given for numbers:
oByte - Positive integers between 1 and 255
oInteger - Positive and negative integers between -32,768 and 32,768
o Long Integer (default) - Larger positive and negative integers between -2 billion and 2 billion.
o Single - Single-precision floating-point number o Double - Double-precision floating-point
number o Decimal - Allows for Precision and Scale property control

 Format confirms the data in the field to the same format when it is entered into the datasheet. For text and
memo fields, this property has two parts that are separated by a semicolon. The first part of the property is
used to apply to the field and the second applies to empty fields.

Primary Key

Every record in a table must have a primary key that differentiates it from every other record in the table. In
some cases, it is only necessary to designate an existing field as the primary key if you are certain that every
record in the table will have a different value for THAT PARTICULAR FIELDS. A social security number is
an example of a record whose values will only appear in a database table.

Figure 9.5 Quick Access Toolb ar – Table Tools


Designate the primary key field by right -clicking on the record and selection Primary Key
from the shortcut menu or select Primary Key from the Quick Access Toolb ar as given in
figure above . The primary key field will be noted with a key i mage to the left. To remove
a primary key, repeat one of these steps.

Indexes
Creating indexes allows Access to query and sort records faster. To set an indexed field,
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

select a field that is commonly searched and change the Indexed property to Yes (Duplicates OK) if multiple entries
of the same data value are allowed or Yes (No Duplicates) to prevent duplicates.

Field Validation Rules

Validation Rules specify requirements (change word) for the data entered in the worksheet. A customized
message can be displayed to the user when data that violates the rule setting is entered. Click the expression
builder ("...") button at the end of the Validation Rule box to write the validation rule. Examples of field
validation rules include <> 0 to not allow zero values in the record, and ??? to only all data strings three
characters in length.

Input Masks

An input mask controls the value of a record and sets it in a specific format. They are similar to the Format
property, but instead display the format on the datasheet before the data is entered. For example, a telephone
number field can formatted with an input mask to accept ten digits that are automatically formatted as "(555)
123-4567". The blank field would look like (___) ___-____. Add an input mask to a field by following these
steps:
 In design view, place the cursor in the field that the input mask will be applied to.
 Click in the white space following Input Mask under the General tab.
 Click the "..." button to use the wizard or enter the mask, (@@@) @@@-@@@@, into the field provided.

DATASHEET RECORDS

Adding Records

Add new records to the table in datasheet view by typing in the record beside the asterisk (*) that marks the
new record.

Editing Records

To edit records, simply place the cursor in the record that is to be edited and make the necessary changes. Use
the arrow keys to move through the record grid. The previous, next, first, and last record buttons at the bottom
of the datasheet are helpful in maneuvering through the datasheet.

Deleting Records

Delete a record on a datasheet by placing the cursor in any field of the record row and select Delete Record
from the menu bar or click the Delete button on the Quick Access toolbar.

Adding and Deleting Columns

Although it is best to add new fields (displayed as columns in the datasheet) in design view because more
options are available, they can also be quickly added in datasheet view. Highlight the column that the new
column should appear to the left of by clicking its label at the top of the datasheet and press right click then
select Insert field from the dropdown menu. Entire columns can be deleted by placing the cursor in the column
and selecting Delete field from the dropdown menu.

Freezing and unfreezing Columns


Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Similar to freezing panes in Excel, columns on an Access table can be frozen. This is helpful if the datasheet
has many columns and relevant data would otherwise not appear on the screen at the same time. Freeze a
column by placing the cursor in any record in the column and select Freeze fields from the right click
dropdown men. Select the same option to unfreeze a single column or select Unfreeze All fields.

Finding Data in a Table

Open the table in datasheet view. Place the cursor in any record in the field that you want to search and select
Home|Find (Ctrl + F)... from the Quick Access toolbar. Enter the value criteria in the Find What: box. From
the Look In: drop-down menu, define the area of the search by selecting the entire table or just the field in the
table you placed your cursor in during step 2. Select the matching criteria from Match: to and click the More
> button for additional search parameters. When all of the search criteria are set, click the Find Next button.
If more than one record meets the criteria, keep clicking Find Next until you reach the correct record.

Table Relationships

To prevent the duplication of information in a database by repeating fields in more than one table, table
relationships can be established to link fields of tables together.

Once you are in Design view or in datasheet view of a table, Table Tools Menu is automatically highlighted then
click the Relationships button on the toolbar. . From the Show Table window (click the Show Table button
on the toolbar to make it appear), double click on the names of the tables or queries you would like to include
in the relationships. When you have finished adding tables or queries, click Close. To link fields in two
different tables, click and drag a field from one table to the corresponding field on the other table and release
the mouse button. The Edit Relationships window will appear. From this window, select different fields if
necessary and select an option from Enforce Referential Integrity if necessary. These options give Access
permission to automatically make changes to referential tables if key records in one of the tales is deleted or
updated. Check the Enforce Referential Integrity box to ensure that the relationships are valid and that the data
is not accidentally deleted when data is added, edited, or deleted. Click Create to create the link. A line now
connects the two fields in the Relationships window. The datasheet of a relational table will provide expand and
collapse indicators to view subdatasheets containing matching information from the other table.

Sorting & Filtering

Sorting and filtering allow you to view records in a table in a different way either by reordering all of the
records in the table or view only those records in a table that meet certain criteria that you specify.

Sorting

In table datasheet view, place the cursor in the column that you want to sort by. Select Ascending or
Descending from the Quick Access toolbar under Home main menu or click the Sort A to Z or Sort Z to A
from the dropdown menu.

To sort by more than one column (such as sorting by date and then sorting records with the same date
alphabetically), highlight the columns by clicking and dragging the mouse over the field labels and select one
of the sort methods stated above.
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
Filter by Selection

This feature will filter records that contain identical data values in a given field such as filtering out all of the
records that have the value "Smith" in a name field. To Filter by Selection, place the cursor in the field that
you want to filter the other records by and click the Selection button inside Home main menu on the toolbar or
directly select the criteria from right click dropdown menu.

Filter by Form

If the table is large, it may be difficult to find the record that contains the value you would like to filter by so
using Filter by Form may be advantageous instead. This method creates a blank version of the table with drop-
down menus for each field that each contains the values found in the records of that field.

The following methods can be used to select records based on the record selected by that do not have exactly
the same value. Type these formats into the field where the drop-down menu appears instead of selecting an
absolute value.

Saving A Filter

The filtered contents of a table can be saved as a query by selecting Advanced|Save As Query. Enter a name
for the query and click OK. The query is now saved within the database.

Remove a Filter

To view all records in a table again, click the depressed toggle Filter button.

EXERCISES

Create the following tables in Microsoft Access:

Table1: Student (containing fields: Student ID, First Name, Last Name, Department and Class).
Table2: Marks (containing fields: Student ID, ITC, Mathematics, English, Electronics, Physics).

Select appropriate primary keys and define appropriate relationship for these two tables. Add some sample data
to the tables and make a hard copy of the tables created.
Attach your printed output.
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 08

OBJECT

Creating queries, forms and reports in Microsoft Access.

INTRODUCTION TO QUERIES

Queries select records from one or more tables in a database so they can be viewed, analyzed, and sorted on a
common datasheet. The resulting collection of records, called a dynaset (short for dynamic subset), is saved as a
database object and can therefore be easily used in the future. The query will be updated whenever the original
tables are updated. Types of queries are select queries that extract data from tables based on specified values, find
duplicate queries that display records with duplicate values for one or more of the specified fields, and find
unmatched queries display records from one table that do not have corresponding values in a second table.

Figure 10.1 Create Menu Quick Access Toolbar

Create a Query in Design View

From the Create Main Menu as in figure 10.1, click the Query Design icon. Select tables and existing queries from
the Tables and Queries tabs and click the Add button to add each one to the new query. Click Close when all of the
tables and queries have been selected. Add fields from the tables to the new query by double-clicking the field
name in the table boxes or selecting the field from the Field: and Table: drop-down menus on the query form.
Specify sort orders if necessary.

Enter the criteria for the query in the Criteria: field. The Expression Builder can also be used to assist in writing
the expressions. After you have selected all of the fields and tables, click the Run button on the toolbar. Save the
query by clicking the Save button.

Query Wizard

Click the Create query by using wizard icon in the database window to have Access step you through the process
of creating a query. From the first window, select fields that will be included in the query by first selecting the
table from the drop-down Tables/Queries menu. Select the fields by clicking the > button to move the field from
the Available Fields list to Selected Fields. Click the double arrow button >> to move all of the fields to Selected
Fields. Select another table or query to choose from more fields and repeat the process of moving them to the
Selected Fields box. Click Next > when all of the fields have been selected. On the next window, enter the name
for the query and click Finish.

Find Duplicates Query

This query will filter out records in a single table that contain duplicate values in a field. Click the New button on the
Queries database window, select Find Duplicates Query Wizard from the New Query window and click OK. Select the
table or query that the find duplicates query will be applied to from the list provided and click Next >. Select the
40
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

fields that may contain duplicate values by highlighting the names in the Available fields list and clicking the >
button to individually move the fields to the Duplicate-value fields list or >> to move all of the fields. Click Next >
when all fields have been selected. Select the fields that should appear in the new query along with the fields
selected on the previous screen and click Next >. Name the new query and click Finish.

Delete a Query

To delete a query, select the required query and press the Delete key on the keyboard.

FORMS

Forms are used as an alternative way to enter data into a database table.

Create Form by Using Wizard

From the Create Main Menu as in figure 10.1, click Form wizard option in Forms section. From the Tables/Queries
drop-down menu, select the table or query whose datasheet the form will modify. Then, select the fields that will be
included on the form by highlighting each one the Available Fields window and clicking the single right arrow button
> to move the field to the Selected Fields window. To move all of the fields to Select Fields, click the double right
arrow button >>. If you make a mistake and would like to remove a field or all of the fields from the Selected
Fields window, click the left arrow < or left double arrow << buttons. After the proper fields have been selected,
click the Next > button to move on to the next screen. On the second screen, select the layout of the form.

 Columnar - A single record is displayed at one time with labels and form fields listed side-by-side in columns.
 Justified - A single record is displayed with labels and form fields are listed across the screen.
 Tabular - Multiple records are listed on the page at a time with fields in columns and records in rows.
 Datasheet - Multiple records are displayed in Datasheet View

Click the Next > button to move on to the next screen. Select a visual style for the form from the next set of options
and click Next >. On the final screen, name the form in the space provided. Select "Open the form to view or enter
information" to open the form in Form View or "Modify the form's design" to open it in Design View. Click Finish
to create the form.
Adding Records Using A Form

Input data into the table by filling out the fields of the form. Press the Tab key to move from field to field and
create a new record by clicking Tab after the last field of the last record. A new record can also be created at any
time by clicking the New Record button at the bottom of the form window. Records are automatically saved as
they are entered so no additional manual saving needs to be executed.

Editing Forms

The following points may be helpful when modifying forms in Design View:

 Grid lines - By default, a series of lines and dots underlay the form in Design View so form elements can be
easily aligned. To toggle this feature on and off right click and select Grid.
 Resizing Objects - Form objects can be resized by clicking and dragging the handles on the edges and corners
of the element with the mouse.
 Change form object type - To easily change the type of form object without having to create a new one, right
click on the object with the mouse and select Change To and select an available object type from the list.
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

 Label/object alignment - Each form object and its corresponding label are bounded and will move together
when either one is moved with the mouse. However, to change the position of the object and label in relation to

 eachother (to move the label closer to a text box, for example), click and drag the large handle at the top, left
corner of the object or label.
 Tab order - Alter the tab order of the objects on the form by selecting Tab Order from design Menu when
Form is active. Click the gray box before the row you would like to change in the tab order, drag it to a new
location, and release the mouse button.
 Form Appearance - Change the background color of the form by clicking the Shape Fill button on the format
menu inside Form Design. Change the color of individual form objects by highlighting one and selecting a
color from Color palette on the formatting toolbar. The font and size, font effect, font alignment, border around
each object, the border width, and a special effect can also be modified using the formatting toolbar buttons
inside Form Design Tools.

Form Controls

This section explains the uses for other types of form controls including lists, combo boxes, checkboxes, option
groups, and command buttons.
• List and Combo Boxes: If there are small, finite number of values for a certain field on a form, using combo or
list boxes may be a quicker and easier way of entering data. These two control types differ in the number of
values they display. List values are all displayed while the combo box values are not displayed until the arrow
button is clicked to open.

• Check Boxes and Option Buttons: Use check boxes and option buttons to display yes/no, true/false, or on/off
values. Only one value from a group of option buttons can be selected while any or all values from a check box
group can be chosen. Typically, these controls should be used when five or fewer options are available. Combo
boxes or lists should be used for long lists of options.

• Command Buttons: Command buttons provide you with a way of performing action(s) by simply clicking
them. When you choose the button, it not only carries out the appropriate action, it also looks as if it's being
pushed in and released.

Reports

Reports will organize and group the information in a table or query and provide a way to print the data in a database.

Using the Wizard

From the Create Main Menu as in figure 10.1, click Report Wizard option in the Reports section. Select the information
source for the report by selecting a table or query from the Tables/Queries drop-down menu. Then, select the fields that
should be displayed in the report by transferring them from the Available Fields menu to the Selected Fields window
using the single right arrow button > to move fields one at a time or the double arrow button
> to move all of the fields at once. Click the Next > button to move to the next screen.

Select fields from the list that the records should be grouped by and click the right arrow button > to add those fields to
the diagram. Use the Priority buttons to change the order of the grouped fields if more than one field is selected. Click
Next > to continue. If the records should be sorted, identify a sort order here. Select the first field that records should be
sorted by and click the A-Z sort button to choose from ascending or descending order. Click Next > to continue. Select a
layout and page orientation for the report and click Next >. Select a color and graphics style for
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
the report and click Next >. On the final screen, name the report and select to open it in either Print Preview or
Design View mode. Click the Finish button to create the report.

Create in Design View

Click Report Design button in the Reports section of create access toolbar and you will be presented with a blank
grid. Automatically properties window will open for this newly being created report. Click on Record Source
property combo box and you will be presented with the list of available tables and queries. Choose the data source
of the report from the drop- down menu and click OK. Design the report in much the same way you would create a
form. For example, double-click the title bar of the Field Box to add all of the fields to the report at once. Then, use
the handles on the elements to resize or move them to different locations, and modify the look of the report as per
your requirements.

EXERCISES

1. For the tables created in laboratory session 08, create the following queries:
• Select students’ marks in all the five courses with his/her first and last name.
• Select the ID of those students who scored less than 40 marks in Mathematics. Attach hard copies of the
results of all the queries created.

2. For the same data base, generate the following reports:


• Report containing First Name, Last Name and marks in FCE. The report should be in descending order with
respect to the marks in FCE.
• Report for each student containing his/her complete personal information along with his/her marks for all
the courses.
Attach hard copies of all the reports.

Attach your printed output.


Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

C –LANGUAGE
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 1
OBJECT

Getting familiar with the Turbo C Integrated Development Environment. Installing and copying the
compiler, changing directory settings.

Theory

Click on Start Runand type the path


\\fileserver\Softwares\Programing Languages Section
A new window will open. From there right click on the folder named as TC3 and select copy. Now Paste in it in
your C or D partition or your USB drive. As a good approach C drive is normally not recommended for C complier
as C drive is a windows system partition.
Assuming that the folder has been copied in the root of D drive,
open D: partition TC3 folder BIN
Double click and open any one of the two TC.exe icons (as shown on right). The
window that opens is the known as the IDE of Turbo C (as shown below)
This IDE window further contains two more windows and a standard tool bar. The blue window is known as
the text editor which is used to write the programs. And the Light bluish green window at the bottom is the
message box which will display the error or other messages.
Before using the IDE there are few parameters and checks which need to be reviewed every time the IDE of
windows is used. Make sure that the folder of TC3 (also known as compiler) has been copied in the root drive
i.e. in the first window of any partition and not in sub folders. e.g.
D:\TC3 is correct but D:\TC3\CP\C language\Class work\TC3 is incorrect.
Opening a new File
Close all windows in the Turbo C IDE (if there are any) by clicking in the small green box on the right top corner
of each window. On the standard tool bar click file, select new. A new Blue window appears. Saving a New File

Press F2 key to save this file. Make sure the path where you save this file is same as of compiler
e.g. D:\TC3\BINthis path is visible at the bottom of save window. The name of the file will always be followed by
.cpp extension (dot cpp).
Opening an existing file
To open any previously saved file, click File, select open, in the path option type D:\TC3\BIN\*.*
Asteric means all. The asteric before the dot means all file names and the asteric after the dot means all file types.
*.cpp means all files with dot cpp extension.
Setting Directory Paths (to be checked each time the Turbo IDE is opened)
Once you have opened and saved a new file some directories need to be changed according to the location of your
compiler in your computer otherwise the compiler make not work properly.
On the standard toolbar click on options then directories. Set the first letter of the first two paths (i.e. Include
Directories and Library Directories) according to the location of the compiler or say the letter of the directory
where you copied your compiler. The other two paths (i.e. Output Directories and Source Directories) will remain
blank. e.g
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Compilation and Output

After you have written the program press Ctrl+f9 to compile and check the output.
Alt+F5 key is used to display the output for last compilation.

Technical Exits
To minimize the screen of Turbo C editor press Alt+Enter.
If some where the program hangs up compiler at output or gets busy without passing control to programmer press
Ctrl+Pause\Break
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 12
OBJECT
Making first program in C. Saving / copying files to USB or other storage devices.

THEORY
How to work in a Turbo C environment. Basic Startup. Here is simple C language program.

#include<stdio.h> Header
Files
#include<conio.h>

Main function returning no values void main(void) Main function accepting


{

Start and end of main


functions body printf("My First Program");
getch();
}
#include<stdio.h>
#include<conio.h>

The first line of this program is #include<stdio.h>. Here #include tells the compiler to include
something and stdio means
Standard Input/Output whereas .h means that it is a header file or in short we are including standard
input/output header file. In the same way the next line is similar to the first one but it has conio.h in it
where conio means the black colour console screen where we see our output and .h tells us that this is a
header file. In other words we tell the compiler that we are including two files and the code we will
write will be of c language as the compiler also supports C++ code.

void main(void)

This is third line. The first word in this is void which means anything that has no value or is useless. The
next word is main which is the brain function and is the only function readable in most programming
languages. All the other functions are called within the main function. The third word within brackets is
also void. The first void means that the main function won’t return any value while the second void
means that the main function is not going to accept any value. This complete line means that we have
declared the main function here. For example a simple calculator takes two or more numbers from you
and returns the result like addition, subtraction, multiplication etc. It may be confusing at this time to
understand the void functionality but in experiment 11 we will discuss it in detail.
{

Following the main function line is a curly bracket which marks the starting of mains body. Always
remember that if any bracket is opened in C language it needs to be closed hence the last line of the
above program marks the ending of main function.

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science

This is the first function called inside the main body. All functions will always have a round bracket
closing ‘)’ and a semicolon ‘;’ at their end. In that way we easily recognize the number of functions in a
program. According to this rule we can identify 3 functions in this program. However other properties in
different functions may differ but this identity will be common in all functions. clrscr is short form of
clear screen. It clears the screen of any previous output. If not used won’t create any error but output will
show all previous compilation result.

printf(“My First Program”);

This line has another function known as printf which is used for printing. Within the double quotes
is the main body of this function where any character may be printed.

getch();

This is the last function of this program. Its name is short form of get character. Its purpose is to get a
character. It’s used in last to stop the program until a character is entered. If not used won’t show any
error but the output will not stop after compilation. In this case the output is checked manually by
pressing Alt+F5 key.

Example
PROGRAM OUTPUT
#include<stdio.h>
#include<conio.h>
void main(void)
{ My First Program

printf("My First Program");


getch();
}

Exercise
Carefully look at the following programs and write the output.
Program Output

#include<stdio.h>
#include<conio.h>
void main(void) Write the output for the program on left
{
printf("My First Program");
}

#include<stdio.h>
#include<conio.h>
void main(void) Write the output for the program on left
{
getch();
printf("My First Program");
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
#include<stdio.h>
#include<conio.h>
void main(void) Write the output for the program on left
{
getch();
printf("My First Program");
getch();
}

#include<stdio.h>
#include<conio.h>
void main(void) Write the output for the program on left
{
getch();

printf("My First Program");


}

#include<stdio.h>
#include<conio.h>
void main(void)
{ Write the output for the program on left

getch();
printf("My First Program");

#include<stdio.h>
#include<conio.h>
void main(void)
{
getch(); Write the output for the program on left

printf("My First Program");


getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
getch(); Write the output for the program on left
printf("My First Program");
getch();

}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science
include<stdio.h>
#include<conio.h>
void main(void) Write the output for the program on left
{

getch();
printf("My First Program");
getch();
}

#include<conio.h>
#include<stdio.h>
void main(void) Write the output for the program on left
{

printf("My First Program");


getch();
}

#include”conio.h”
#include”stdio.h”
void main(void)
Write the output for the program on left
{

printf("My First Program");


getch();
}
#include<conio.h>
#include<stdio.h>
main()
{

printf("My First Program");


getch();
}

#include<CONIO.H>
#include<STDIO.H>
void main(void)
Write the output for the program on left
{

printf("My First Program");


getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Assignment
Using the program below, make a resume showing your complete details.
Program

#include<stdio.h>
#include<conio.h>
void main(void)
{
printf("\n****************************RESUME****************************");
printf("\n******************************CV******************************");
printf("\n**************************************************************");
printf("\n==============================================================");
printf("\nName : Abc");
printf("\nFathers Name : Xyz");
printf("\nDate of Birth : dd-mm-yyyy");
printf("\nAddress : Engineering Department, Main Campus, Iqra University,");
printf("\n Shaheed-e-Millat Road, Defence View Karachi"); printf("\nCNIC :
XXXXX-XXXXXXX-X"); printf("\nGender : Male");

printf("\nHSC (College\\Board) : Science (Pre Engg), Iqra College, Karachi Board");


printf("\nHSC Year : August 2005 ");
printf("\nSSC (School\\Board) : Science, Iqra School, Karachi Board");
printf("\nSSC Year : August 2003 ");
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 2
Objective
Understanding and Using format specifiers and escape sequences with printf.

Theory
Format specifiers are used to substitute and print values inside a printf or scanf statement which are further applicable on
variables. Below is a chart of format specifier examples using printf.

No. Type Syntax Value Example


1 Single Character %c One character within single quotes printf(“%c”,’a’);
2 String %s A sentence of an unfixed length within double printf(“%s”,”Iqra Univ”);
3 Decimal Integer %d Any whole number between -32,768 to printf(“%d”,12345);
4 Long Integer %ld Any number between -2,147,483,648 to printf(“%ld”,1234567);
5 Float %f Any decimal point number between 10
38
to printf(“%f”,1234.567);
6 Double %lf Any decimal point number between
308
10 printf(“%lf”,12345678);

Escape Sequences are used to adjust spacing between lines or characters or the characters themselves.
No. Syntax Application Example
1 \n New Line printf(“\n”);
2 \t Tab eight spaces to right printf(“\t”)
3 \b Back space One space back printf(“\b”);
4 \r Carriage return Start of same line printf(“\r”)
5 \’ Printing single quote printf(“\’”
6 \” Printing double quotes printf(“\””
7 \\ Printing back space printf(“\\”)
8 \xdd Printing characters by Hexa decimal ASCII value printf(“\x45”);
9 \ddd Printing characters by decimal ASCII value printf(“\d45”);

Example
Program Output
#include<stdio.h>
#include<conio.h>
void main(void)
{
A
Iqra University
printf("\n%c",'a');
20
printf("\n%s","Iqra University");
35.5
printf("\n%d",20);
printf("\n%f",35.5); 1234567
printf("\n%ld",1234567);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
A Iqra University 2035.5 1234567
printf("\n%c %s %d %f %ld",'a',"Iqra
University",20,35.5,134567);
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Exercise
Write the output for following programs and give reasons.
Program Output
#include<stdio.h> Write the output for the program on
#include<conio.h> left
void main(void)
{
printf("\n%d
",'a');
printf("\n%s","Iqra
University");
printf("\n%c",20);
printf("\n%f",35.5);
printf("\n%ld",1234567);
getch();

Assignment
Use the program below to make your resume with format specifiers and escape sequences showing your complete details.
Program

#include<stdio.h>
#include<conio.h>
void main(void)
{

printf("\t\t\t\n****************************RESUME****************************
");
printf("\t\t\t\n******************************CV******************************");
printf("\t\t\t\n**************************************************************");
printf("\t\t\t\n=========================================================
====="); printf("\nName : %s","Abc");
printf("\nFathers Name : %s","Xyz");
printf("\nDate of Birth : %d-%d-%d",11,11,1989);
printf("\nAddress : %s","Engineering Department, Main Campus, Iqra University,");
printf("\n %s","Shaheed-e-Millat Road, Defence View Karachi");
printf("\nCell Phone : 0%d-%ld",300,1234567);
printf("\nCNIC : %d-%ld-%d",12345,1234567,1);
printf("\nGender : %s","Male");
printf("\nHSC (College\\Board) : %s","Science (Pre Engg), Iqra College, Karachi Board");
printf("\nHSC Year : %s %d","August",2005);
printf("\nSSC (School\\Board) : %s","Science, Iqra School, Karachi Board");
printf("\nSSC Year : %s %d","August",2003);
getch();
}

Introduction to Computer & Programming____________________________________________


IQRA University – Department of Computer Science

Lab Session 3
Objective
Studying different data types, variables, variable names, variable declaration, variable definition, variable initialization, escape
sequences.

Theory
Variables are declared by first writing
data types followed be a variable name, e.g.

int a=10;

Here

int is data type,


a is variable name
and after the equals to sign (=) is the value in it 10 the
value is always followed by a terminator

Supported Example
No. Data Type Syntax format Specifier Value
1 Single Character char %c One character within single quotes char a=’a’;
2 Decimal Integer int %d Any whole number between -32,768 to 32,767 int a=10;
3 Long Integer long int %ld Any number between -2,147,483,648 to 2,147,483,647 long int a=12345;
-38 38
4 Float float %f Any decimal point number between 10 to 10 float a=1234.567;
-308 308
5 Double double %lf Any decimal point number between 10 to 10 double a=123456;

Variable Names
Variable names will always start with an alphabet.
Variable names can contain numbers (1,2,45,66) and underscores (_) but no other special characters (!@#$%^&*). Variable
names cannot resemble to any predefined word e.g. include, printf, getch, scanf etc..
A variable name cannot be used for multiple declarations.

Example
Program Output
#include<stdio.h>
#include<conio.h>
void main(void)
{ char
a='a';
int b=12;

float c=12.5; a 12 12.5 1234567 double d=1234567;


printf("%c %d %f %lf",a,b,c,d);
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{

char a='a',a1=’b’;
int b=12,b1=13; b 13 13.5 1234568 float c=12.5,c1=13.5;

double d=1234567,d1=1234568;
printf("\n%c54 %d %f %lf",a,b,c,d);
printf("\n%c %d %f %lf",a1,b1,c1,d1);
getch();
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Exercise
Write the output for following programs.
Program Output
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{
char a=97;
int b=’A’;
float c=12.5;
double d=1234567;
printf("%c %d %f %lf",a,b,c,d);
getch();
}

Assignment
Using the program below, make a resume with format variables showing your complete details.
Program
#include<stdio.h>
#include<conio.h>
void main(void)
{

int dd,mm,yyyy,cell1,cnic3;
long int cnic1,cnic2,cell2;
dd=11;
mm=11;
yyyy=1989;
cell1=300;
cell2=1234567;
cnic1=12345;
cnic2=1234567;
cnic3=1;
printf("\n****************************RESUME****************************"); printf("\
n******************************CV******************************");
printf("\
n**************************************************************");
printf("\
n==============================================================");
printf("\nName : %s","Abc");
printf("\nFathers Name : %s","Xyz");
printf("\nDate of Birth : %d-%d-%d",dd,mm,yyyy);
printf("\nAddress : %s","Engineering Department, Main Campus, Iqra University,");
printf("\n %s","Shaheed-e-Millat Road, Defence View Karachi");
printf("\nCell Phone : 0%d-%ld",cell1,cell2);
printf("\nCNIC : %ld-%ld-%d",cnic1,cnic2,cnic3);
printf("\nGender : %s","Male");
printf("\nHSC (College\\Board) : %s","Science (Pre Engg), Iqra College, Karachi Board");
printf("\nHSC Year : %s %d","August",2005);
printf("\nSSC (School\\Board) : %s","Science, Iqra School, Karachi Board");
printf("\nSSC Year : %s %d","August",2003);
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 4

Objective
Studying Math functions.

Theory
Math.h header file is included for the definitions of math functions listed below. It is written as #include<math.h>.

Trignometic / Maths
Functions
sin(n)
cos(n)
tan(n)
sinh(n)
hosh(n)
tanh(n)
pow(nmb,pwr)
sqrt(n)

Example
The program below shows the result for math and trigonometric functions. The functions pass the values to variables
which are further used for printing in printf.

Program Output
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(void)
{

float a=45,b=1,sn,cs,tn,snh,csh,tnh;
sn=sin(a);
cs=cos(a);
tn=tan(a); Trignometric Functions
sin 45 = 0.85
snh=sinh(b); cos 45 = 0.53
csh=cosh(b); tan 45 = 1.62
tnh=tanh(b);

printf("\n\n\n Trignometric Functions"); Hyperbolic Functions


printf("\nsin 45 = %.2f",sn); sinh 1 = 1.18
printf("\ncos 45 = %.2f",cs); cosh 1 = 1.54
printf("\ntan 45 = %.2f",tn); tanh 1 = 0.76

printf("\n\n\n Hyperbolic Functions");


printf("\nsinh 1 = %.2f",snh);
printf("\ncosh 1 = %.2f",csh);
printf("\ntanh 1 = %.2f",tnh);

getch();
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

The program below shows the result for math and trigonometric functions. It also demonstrates that some functions may be
called within the body of another function. For example here all the trigonometric functions are called inside printf function.

Program Output
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(void) Trignometric Functions sin
{ 45 = 0.85
cos 45 = 0.53 tan
45 = 1.62
printf("\n\n\n Trignometric Functions");
printf("\nsin 45 = %.2f",sin(45)); Hyperbolic Functions
printf("\ncos 45 = %.2f",cos(45));
sinh 1 = 1.18
printf("\ntan 45 = %.2f",tan(45)); cosh 1 = 1.54 tanh
1 = 0.76
printf("\n\n\n Hyperbolic Functions");
printf("\nsinh 1 = %.2f",sinh(1));
printf("\ncosh 1 = %.2f",cosh(1)); Math Functions pow
printf("\ntanh 1 = %.2f",tanh(1)); 2,3 = 8.00 sqrt 49
= 7.00
printf("\n\n\n Math Functions");
printf("\npow 2,3 = %.2f",pow(2,3));
printf("\nsqrt 49 = %.2f",sqrt(49));

getch();
}

Assignment
Assingment
Program the following.
• Implement the following equation

3x4 sin(180x) + 4x3 cos(90x) + x2sin(tan(45)) + 7x + 9cos(90x2 )

where x may be user defined value.


Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Scanf command can take input of different data types at a time.


Gerche command can take only one character input.

Example
Write the output after supplying appropriate input on console screen.

Program Output
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

char a;
int b;
float c;
double d;
printf("\nEnter character ");
scanf("%c",&a);
printf("\nEnter integer ");
scanf("%d",&b);
printf("\nEnter float ");
scanf("%f",&c);
printf("\nEnter double ");
scanf("%lf",&d);
printf("\n%c %d %f %lf",a,b,c,d);
getch();
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

char a;
int b;
float c;
double d;
printf("Enter char integer float double\n");
scanf("%c %d %f %lf",&a,&b,&c,&d);
printf("\n%c %d %f %ld",a,b,c,d);
getch();
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

printf("\nWhat is your section : ");


getche();
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Assignment
Use the program below to make a resume that takes input from the user and shows complete details.
Program

#include<stdio.h>
#include<conio.h>
void main(void)
{

int dd,mm,yyyy,cell1,cnic3;
long int cnic1,cnic2,cell2; printf("\
n****************************RESUME*********************
*******");
printf("\n******************************CV*************************
*****");
printf("\n**********************************************************
****");
printf("\n===================================================
==========="); printf("\nName : %s","Abc");
printf("\nFathers Name :
%s","Xyz"); printf("\nDate of Birth
: (dd-mm-yyyy)"); scanf("%d %d
%d",&dd,&mm,&yyyy); printf("%d-
%d-%d",dd,mm,yyyy);
printf("\nAddress : %s","Engineering Department, Main Campus, Iqra University,");
printf("\n %s","Shaheed-e-Millat Road, Defence View Karachi");
printf("\nCell Phone : (3XX-1234567)");
scanf("%d %ld",&cell1,&cell2);
printf("0%d-%ld",cell1,cell2);
printf("\nCNIC : (12345-1234567-
1)"); scanf("%ld %ld
%d",&cnic1,&cnic2,&cnic3);
printf("%ld-%ld-%d",cnic1,cnic2,cnic3);
printf("\nGender : %s","Male");
printf("\nHSC (College\\Board) : %s","Science (Pre Engg), Iqra College, Karachi Board");
printf("\nHSC Year : %s %d","August",2005);
printf("\nSSC (School\\Board) : %s","Science, Iqra School, Karachi Board");
printf("\nSSC Year : %s %d","August",2003);
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Lab Session 5
Objective
Arithmetic operators, conditional operators, assignment operators, Increment/decrement operators.

Theory
Arithmetic Relational Assignment Increment/decrement
operators operators operators operators
Add + Greater Than > Addition += Increment ++
Subtract - Less Than < Subtraction -= Decrement --
Multiplicatio * Greater or >= Multiplication *=
Division / Less or Equal <= Division assignment /=
Remainder % Equal Equal ==
Not Equal !=

Example
Explain the following program after careful study.
Program Output
#include<stdio.h>
#include<conio.h>
main()
{

int a=2,b=4,c1,c2,c3,c4,d1,d2,d3,d4; 6-280


c1=c2=c3=c4=5; 010101
d1=d2=d3=d4=8; 82151
printf("\n%d %d %d %d",a+b,a-b,a*b,a/b); 8987
printf("\n%d %d %d %d %d
%d",a>b,a<b,a>=b,a<=b,a==b,a!=b);
printf("\n%d %d %d %d",c1+=3,c2-
=3,c3*=3,c4/3); printf("\n%d %d %d

Exercise
Write output for following programs and give reasons.
Program Output
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d",a++,a);
printf("\n%d ",a);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d",++a,a);
printf("\n%d ",a);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d",a - -,a);
printf("\n%d ",a);
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Program Output
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d",- -a,a);
printf("\n%d ",a);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d %d %d",a++,++a,a,a - -);
printf("\n%d ",a);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d %dd",a+5,++a,a);
printf("\n%d ",a);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d %dd",a+=5,++a,a);
printf("\n%d ",a);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d %dd",a-=5,- -a,a);
printf("\n%d ",a);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
main()
{

int a=5;
printf("\n%d %d %dd",a+=5,a++,a);
printf("\n%d ",a);
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Assingment
Program the following.
• Prompt user to input distance in Kilometers and display it in meters.
• For the following equation 3x4 + 4x3 + x2 + 7x + 9 , substitute the value of x and generate the result.
• Input any number from user and generate its square e.g. square of 8 is 64
• Input any number from user and generate its cube e.g. cube of 8 is 512
• Input a 4 digit number in any integer type variable and sum all the four digits, e.g. int a =3487, result = 22
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Studying loops. For loops, nested for loops, while loops, nested while loops, do while loops, nested do while loops.

Theory
for while do while
initialization;
initialization;
do
for(initialization ; check range ; iteration) while(check range)
{ body
{ {body
iteration;
body iteration;
} while(check range)
} }

Example Nested
This table below shows nested loops
The table below shows simple loops. Loop Program Output All the three programs have
All the three programs have same output. same output
Loop #include<stdio.h>
Program Output #include<conio.h>
void main(void)
{

for(int a=0;a<=3;a++)
#include<stdio.h>
{
#include<conio.h>
For for(int b=0;b<=3;b++)
void main(void) {
{ printf("%d%d\t",a,b);
For }
for(int a=0;a<=12;a++) printf("\n");
printf("%d x 2 = %d\n",a,a*2);
}
getch();
getch();
}
#include<stdio.h>
#include<conio.h>
void main(void)
{
int
a=0,b;
#include<stdio.h> while(a<=3)
#include<conio.h> {
void main(void) b=0;
{ 0x2=0
While while(b<=3)
int 1x2=2 {
a=0; 2x2=4 printf("%d%d\t",a,b); 00 01 02 03
While while(a<=12) 3x2=6 b++; 10 11 12 13
{ 4x2=8 } 20 21 22 23
printf("%d x 2 = %d\n",a,a*2); 5 x 2 = 10 30 31 32 33
printf("\n");
a++; 6 x 2 = 12 a++;
} 7 x 2 = 14 }
getch(); 8 x 2 = 16 getch();
} 9 x 2 = 18
#include<stdio.h>
10 x 2 = 20
#include<conio.h>
11 x 2 = 22
void main(void)
12 x 2 = 24
{
int a=0,b;
#include<stdio.h> do
#include<conio.h> {
void main(void) b=0;
{ do
Do while {
int a=0; printf("%d%d\t",a,b);
do b++;
Do while { }while(b<=3);
printf("%d x 2 = %d\n",a,a*2); printf("\n");
a++; a++;
} }while(a<=3);
while(a<=12); getch();
getch(); }
}
63
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

This program of while loops takes continuous input until enter key is pressed.
Program Output
#include<stdio.h>
#include<conio.h>
void main(void)
{

Type any sentence


int a=0;
Iqra University
printf("Type any sentence\n");
Total Characters typed = 15
while(getche()!='\r')
a++;
printf("\nTotal Characters typed = %d",a);
getch();

Exercise
Carefully observer the following program and write output with reasons.
Program Output
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

for(int a=0;a<=12;a++);
printf("%d x 2 = %d\n",a,a*2);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

for(int a=0;1;a++);
printf("%d x 2 = %d\n",a,a*2);
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

int a=0;
while(0)
{
printf("%d x 2 = %d\n",a,a*2);
a++;
}
getch();
}
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

int a=0,b;
while(a<=3);
{
b=0;
while(b<=3);
{
printf("%d%d\t",a,b);
b++;
}
printf("\n");
a++;
}
getch()
Assignment
• Input any number from user and generate its factorial e.g. factorial of 7 is 5040 For
the following output write programs with a logical method.
Program Output
Write the program for the output on right 10 x 2 = 20
12 x 2 = 24
14 x 2 = 28
16 x 2 = 32
18 x 2 = 36
20 x 2 = 40
Write the program for the output on right 33 32 31 30
23 22 21 20
13 12 11 10
03 02 01 00
Write the program for the output on right 00 00 00 00
00 11 00 00
00 00 22 00
00 00 00 33
Write the program for the output on right 12 x 2 = 24
11 x 2 = 22
10 x 2 = 20
9 x 2 = 18
8 x 2 = 16
7 x 2 = 14
6 x 2 = 12
5 x 2 = 10
4x2=8
3x2=6
2x2=4
1x2=2
#include<stdio.h> Explain the program on left and its output which is given
#include<conio.h> below
void main(void)
{
int a,b,c;
for(a=1;a<=9;a+=2)
{
for(b=9;b>a;b--)
printf(" "); 1
333
for(c=1;c<=a;c++) 55555
printf("%d ",a); 7777777
999999999
printf("\n");
}
getch();
}
#include<stdio.h> Explain the program on left and its output which is given
#include<conio.h> below
void main(void)
{

int a,b;
long float c=1; 1
for(a=0;a<=8;a++) 121
{ 12321
for(b=8;b>a;b--) 1234321
printf(" "); 123454321
12345654321
printf("%.lf ",c*c); 1234567654321
printf("\n"); 1234567876543 2 1
c=c*10+1;
}
getch();
Write the program for the output on right +
+ + +
+ + + + +
+ + + + + ++
+ + + + + + ++ +
Use the program below to make a resume that takes input from the user using while loop and shows complete detail
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Program

#include<stdio.h>
#include<conio.h>
void main(void)
{

int
dd,mm,yyyy,cell1,cnic
3;
long int
cnic1,cnic2,cell2;

printf("\n****************************RESUME****************************");
printf("\n******************************CV******************************"); printf("\
n**************************************************************"); printf("\
n=================================== ==============
============="); printf("\nName : ");
while(getche()!='\r');
printf("\nFathers Name : ");
while(getche()!='\r');
printf("\nDate of Birth : (dd-mm-yyyy)");
scanf("%d %d
%d",&dd,&mm,&yyyy);
printf("%d-%d-
%d",dd,mm,yyyy);
printf("\nAddress : ");
while(getche()!='\r');
printf("\nCell Phone : (3XX-1234567)");
scanf("%d %ld",&cell1,&cell2);
printf("0%d-%ld",cell1,cell2);
printf("\nCNIC : (12345-
1234567-1)"); scanf("%ld %ld
%d",&cnic1,&cnic2,&cnic3);
printf("%ld-%ld-
%d",cnic1,cnic2,cnic3);
printf("\nGender : ");
while(getche()!='\r');
printf("\nHSC (College\\Board) : ");
while(getche()!='\r');
printf("\nHSC Year : %s %d","August",2005);
printf("\nSSC (School\\Board) : ");
while(getche()!='\r');
printf("\nSSC Year : %s %d","August",2003);
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

Decision making and conditioning using If statements, If-else statements, switch-case.

Theory
If Nested If If-else Else-if Switch-case
if(cond) if(cond) if(cond) if(cond) switch(cond)
{ { { { {
Body If(cond) body body case’1‘:
} { } } else body
body else If(cond) case’2‘:
} { { body
} Body Body }
} }

Example
This program illustrates simple if and nested if statements with else conditions
Program Output
#include<stdio.h>
#include<conio.h>
void main(void)
{

char ch;
int chr=0,wrd=1;
printf("Type any sentence\n");
while((ch=getche())!='\r')
Type any sentence
{
Iqra Univ Khi Sindh Pak
chr++;
if(ch==' ') Total Characters = 19
Total Words = 5
{
wrd++;
chr--;
}
}
printf("\nTotal Characters = %d",chr);
printf("\nTotal Words = %d",wrd);
getch();
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

int cp=0;
printf("Enter CP marks between 1 & 100\n");
scanf("%d",&cp);
if(cp>=0 && cp<=100)
{
if(cp>=75)
printf("\nGrade A");

else if(cp>=50)
printf("\nGrade C");
}
else
printf("\nIncorrect Input");
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

This program lets the user choose a number between 1 and 99 and guesses it in less than 10 hints.
Program Output
#include<stdio.h>
#include<conio.h>
void main(void)
{

float gss,incr;
char ch;
printf("Think of a number Between 1 & 99\n");
printf("Press `g` for grater\n"); Think of a number between 1 and 99
printf("Press `l` for less\n"); Press `g` for greater
printf("Enter for exit\n"); Press `l` for less
Enter for exit
incr=gss=50;
while(incr>1.0) Is your number greater, less or equal to 50
{
printf("\nIs your number greater, less or equal to %.0f\n",gss); Is your number greater, less or equal to 75
incr/=2;
if((ch=getch())=='e') Is your number greater, less or equal to 88
break; You guessed 88
else if(ch=='g')
gss+=incr;
else
gss-=incr;
}
printf("You guessed %.0f",gss);
getch();

This program prompts the user to type his/her name. If any thing other than Upper/lower case alphabets or a space is
entered for example 1,2,@#$% then it is detected and nothing is printed until a correct character is input.

Program Output
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

char ch;
printf("Name : ");
while((ch=getche())!='\r')
{
if( (ch>=65 && ch<=90) || (ch>=97 && ch<=122) || ch==' ' );
else
printf("\b \b");
}
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

This is a simple calculator program that adds or subtracts two numbers entered by the user.

Program Output
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

float nm1=1.0,nm2=1.0;
char op;

while(!(nm1==0.0 && nm2==0.0))


{
printf("\nType Number Operatot Number\n");
scanf("%f %c %f",&nm1,&op,&nm2);
switch(op)
{
case'+':
printf(" = %f ",nm1+nm2);
break;
case'-':
printf(" = %f ",nm1-nm2);
break;
default:
printf("\nUnknown Operator\n");
}
printf("\n\n");
}
getch();
}
Introduction to Computer & Programming____________________________________________
IQRA University – Department of Computer Science

This is same as the previous one except it take numbers instead of operators to show that switch can also accept
numbers.
Program Output
#include<stdio.h> Write the output for the program on left
#include<conio.h>
void main(void)
{

float nm1=1.0,nm2=1.0;
int op;

while(!(nm1==0.0 && nm2==0.0))


{
printf("\nType Number Operator Number\n");
printf("\nType 1 for addition and 2 for subtraction in operator\n");
scanf("%f %d %f",&nm1,&op,&nm2);
switch(op)
{
case 1:
printf(" = %f ",nm1+nm2);
break;
case 2:
printf(" = %f ",nm1-nm2);
break;
default:
printf("\nUnknown Operator\n");
}
printf("\n\n");
}
getch();

Assingment
Program the following.
• Make the number guessing program with switch case.
• Make an alphabet guessing program using if-else.
• Complete the simple calculator program for multiplication and division. Also make it using if-else.
• Make your resume such that in the name field it dose not accept any thing else than alphabets and space bar.
• Look at the scenario below.
Marks Grade GPA
Design a marks sheet for a student with 5 subjects 0-49 F 2
Math, Physics, Electronics, Islamiat, Computer Programming. 50-59 C 2.25
Take marks as input from user calculate grade for each subject, 60-69 C+ 2.5
70-79 B 2.75
CGPA and percentage. Detect error for out ranged numbers e.g. below 0 or 80-89 B+ 3
above . 90-95 A 3.5
96-90 A+ 4

You might also like