0% found this document useful (0 votes)
7 views91 pages

XII C Language & Database Practical Guide

The document is a practical file for XII students, specifically focusing on C programming and Access Database for the academic year 2020-21. It includes various practical exercises such as calculating leap years, generating marks sheets, and creating databases, along with flowcharts, algorithms, and coding examples. The file is authored by Mohsin Ahmed Khan Ghori and serves as a guidance resource for students at Pakistan Shipowners’ Govt. College.

Uploaded by

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

XII C Language & Database Practical Guide

The document is a practical file for XII students, specifically focusing on C programming and Access Database for the academic year 2020-21. It includes various practical exercises such as calculating leap years, generating marks sheets, and creating databases, along with flowcharts, algorithms, and coding examples. The file is authored by Mohsin Ahmed Khan Ghori and serves as a guidance resource for students at Pakistan Shipowners’ Govt. College.

Uploaded by

Ahnaf Shiekh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

After Lockdown COVID-19, Practical File 2020 for XII Student’s Guidance from Mohsin Ahmed Khan

Ghori (Lecturer)

C Roll No: 15559


Language Muhammad
Hasan Khan
&
Database 2020-21
XII-Practical of Board of ‫)دوئم( سال انٹر‬
Intermediate Education ‫سال تعلیمی‬
Karachi for the year
۲۰۲۰‫؀‬ ۲۱

Mohsin Ahmed Khan Ghori (Lecturer) / Pakistan ShipOwners’ Govt. College,


[Link]
XII PRACTICAL C & Access Database 2020-21

NAME Muhammad Hasan Khan

FATHER NAME Mohsin Ahmed Khan

CLASS XII

GROUP Science General

ROLL NO 15559

EMAIL HasanKhan@[Link]

CONTACT 02136320000

COLLEGE Pakistan Shipowners’ Govt. Degree College

SESSION 2020-2021

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 2


XII PRACTICAL C & Access Database 2020-21

Certificate

This is to certify that Mr. Muhammad Hasan Khan s/o Mohsin

Ahmed Khan, holding Roll No.15559 of XII class, section A, has

successfully completed all the requirement of this practical file for

the session 2020-21.

Course Instructor Head of the Department

(Mohsin Ahmed Khan Ghori)

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 3


XII PRACTICAL C & Access Database 2020-21

TABLE OF CONTENTS
[Link]. Practical Page
No.
Part-1 C-Language Practical 5 – 58
1 Leap Year 6–8
2 Marks sheet 9 – 12
3 Table of inputted number 13 – 15
4 Factorial of inputted number 16 – 18
5 Inputting three numbers and finds greatest among the 19 – 22
three
6 Area and Volume Calculating program 23 – 26
7 Shatranjh (Chess/Check/Draught) Board 27 – 28
8 ASCII codes 30 – 31
9 Print name Ten(10) Times 33 – 36
10 Prime number checking program 37 – 39
11 Escape Sequences 40 – 43
12 Switch case 44 – 46
13 Pattern Printing Program 47 – 49
14 Function for summing two numbers passed as arguments 50 - 53
15 Payroll of Employee 54 – 58

Part-2 Database Practical 59 - 91


16 Teacher Database 60 – 63
17 Student Database 64 – 67
18 Students Database 68 – 71
19 MyBank Database 72 – 75
20 Library Database 76 – 79
21 Employees Database 80 – 83
22 BankAccount Database (BankAccount,AccountStatus) 84 – 91

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 4


XII PRACTICAL C & Access Database 2020-21

Part-1 C-Language

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 5


XII PRACTICAL C & Access Database 2020-21

Practcial No.1 (Flow Chart- Leap Year)

Start

INPUT “Enter any year to check


whether it’s LEAP year or NOT?
”, makYear

Let factorial=1

Let counter=num

No
IF
makYear%4= 0

Yes

PRINT “Given year”,makYear,”


is LEAP year”

PRINT “Given year”,makYear,”


ISN'T leap year

Stop

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 6


XII PRACTICAL C & Access Database 2020-21

Practcial No.1 (Algorithm- Leap Year)

Step1: BEGIN
Step2:DECLARE makYear AS integer
Step2: WRITE “Enter any year to check whether it’s LEAP year or
NOT? "
Step3: READ, makYear
Step4: IF (makYear%4)=1 THEN
WRITE “Given year “,makYear,” is LEAP year”
ELSE
WRITE “Given year ”,makYear,” ISN’T leap year”
Step5: READ a character
Step6:END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 7


XII PRACTICAL C & Access Database 2020-21

Practcial No.1 (Coding/Programming)


/* ************************************************************************
Object: Write a program that input a year and then check whether its leap year or Not
*************************************************************************/
#include <stdio.h>
#include <conio.h>

int makYear; // variable declaration.

void main(void) // main function.

{ // start of-(sof) body of main function.

clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.01");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter any year to check whether it's LEAP year or NOT? ");
scanf("%d",&makYear);

if(givenYear%4==0)
{printf("\n\t Given year %d is LEAP year",makYear);}
else
{printf("\n\t Given year %d ISN'T leap year",makYear);}

getch(); // pause screen till any button is pressed.

} // end of-(eof) body of main function.

/************************** OUTPUT ***************************************


_______________________________
This is sample Practical No.01;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter any year to check whether it's LEAP year or NOT? 1999

Given year 1999 ISN'T leap year


**************************************************************************

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 8


XII PRACTICAL C & Access Database 2020-21

Practcial No.2 (Flow Chart- Marks sheet)


Start Let counter=0
A

Let total=0 NO Test


For counter< 5

Yes

Let percentage=1.0 PRINT marks(counter)

Let counter= counter + 1


Let counter=0

PRINT total, percentage


NO Test
For counter< 5 No

Yes
NO
Test
INPUT marks(counter) IF percentage<33

Yes

PRINT “FAIL”

Let total=total + marks(counter)

Let counter=counter+1 PRINT “PASS”

Let percentage=total*100.0/500
A Stop

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 9


XII PRACTICAL C & Access Database 2020-21

Practcial No.2 (Algorithm- Marks sheet)


Step1: BEGIN
Step2:DECLARE total,counter AS integer, percentage as real
Step3:DIM marks(5) as integer
Step5: Set total=0, percentage=1.0
Step6: FOR counter=0 to 4 STEP 1
Step7:WRITE “Enter Subject[“,(counter+1),”] marks? “
Step8: READ marks[counter]
Step9: SET total= total + marks[counter]
Step10: NEXT counter
Step11: SET percentage = total * 100.0/500
Step12: FOR counter=0 to 4 STEP 1
Step13:WRITE “ Subject[“, (counter+1), ”= “ ,marks[counter]
Step14: NEXT counter
Step15: WRITE “ Total= “,total, “out of 500”
Step16:WRITE “ Percentage= “,percentage
Step17: IF percentage<33 THEN WRITE “FAIL” ELSE WRITE “PASS”
Step18:READ character
Step19:END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 10


XII PRACTICAL C & Access Database 2020-21

Practcial No.2 (Coding/Programming)


/* ***PSGC***|PRACTICAL02:Write a program that read marks of 5 subjects, calculate the
total marks, percentage & state whether candidate is Pass or Fail.*****/

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

int marks[5],total,counter;
float percentage;
// varible declaration.

void main(void) // main function.

{ // start of-(sof) body of main function.

clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.02");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

total=0;percentage=1.0;

for(counter=0;counter<5;counter++)
{
printf("\n\t Enter Subject [%d] marks? ",counter+1);
scanf("%d",&marks[counter]);

total+=marks[counter];
}

percentage=total*100.0/500;

for(counter=0;counter<5;counter++)
{
printf("\n\t Subject[%d] marks= %d",counter+1,marks[counter]);
}
printf("\n\n\t\tTotal= %d out of 500",total);
printf("\n\n\t\tPercentage= %.2f\n\n\t\t\t",percentage);

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 11


XII PRACTICAL C & Access Database 2020-21

if(percentage<33)
{printf("FAIL");}
else
{printf("PASS");}

getch(); // pause screen till any button is pressed.

} // end of-(eof) body of main function.

/************************* OUTPUT *************************************


_______________________________
This is sample Practical No.02
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Enter Subject [1] marks? 70


Enter Subject [2] marks? 60
Enter Subject [3] marks? 80
Enter Subject [4] marks? 90
Enter Subject [5] marks? 100

Subject[1] marks= 70
Subject[2] marks= 60
Subject[3] marks= 80
Subject[4] marks= 90
Subject[5] marks= 100

Total= 400 out of 500


Percentage= 80.00

PASS
**************************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 12


XII PRACTICAL C & Access Database 2020-21

Practcial No.3 (Flow Chart- Table of Inputted No.)


Start

INPUT makNumber

Let makMultiple=1

No
Test For
makMultiple < 12

Yes

PRINT
makNumber,”*”,makMultiple,”=”,
(makNumber*makMultiple)

Let makMultiple =
makMultiple+1

Stop

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 13


XII PRACTICAL C & Access Database 2020-21

Practcial No.3 (Algorithm- Table of Inputted No.)

Step1: BEGIN
Step2:DECLARE makNumber,makMultiple as integer
Step3: WRITE “Enter any number to generate it’s table? "
Step4: READ makNumber
Step5: FOR makMultiple=1 TO 12 STEP 1
Step6: WRITE
makNumber,”*”,makMultiple,”=”,(makNumber*makMultiple)
Step7: NEXT makMultiple
Step8: READ character
Step9: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 14


XII PRACTICAL C & Access Database 2020-21

Practcial No.3 (Coding/Programming)


/* ***PSGC***|PRACTICAL03: Write program to generate the table of any inputted
number *****/

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

int makNumber,makMultiple; // variables declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.02");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\t Enter any number to generate it's table? ");
scanf("%d",&makNumber);

// for-loop to generate table till 12.


for(makMultiple=1;makMultiple<=12;makMultiple++)
{
printf("\n\t%d * %d = %d"makNumber,makMultiple,(makNumber*makMultiple));
}
getch(); // pause screen till any button is pressed.

} // end of-(eof) body of main function.


/************************** OUTPUT ***************************************
_______________________________
This is sample Practical No.03
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter any number to generate it's table? 5
5*1=5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
5 * 6 = 30
5 * 7 = 35
5 * 8 = 40
5 * 9 = 45
5 * 10 = 50
5 * 11 = 55
5 * 12 = 60
**************************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 15


XII PRACTICAL C & Access Database 2020-21

Practcial No.4 (Flow Chart-Factorial of inputted No.)


Start

INPUT “Enter your number? ”,


num

Let factorial=1

Let counter=num

No
Test
For counter>= 1

Yes

Let factorial= factorial*Counter

PRINT “factorial of “ ,num, ”=”,


factorial

Stop

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 16


XII PRACTICAL C & Access Database 2020-21

Practcial No.4 (Algorithm- Factorial of inputted No.)

Step1: BEGIN
Step2:DECLARE counter,factorial,num AS long integer
Step2: WRITE “Enter Number for Factorial? "
Step3: READ num
Step4: SET factorial=1
Step5: SET counter=factorial
Step7: FOR counter=factorial down to 2 STEP=-1
Step8: SET factorial=factorial*counter
Step9: NEXT counter
Step10:WRITE “Factorial of”, num, “ = " ,factorial
Step11:END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 17


XII PRACTICAL C & Access Database 2020-21

Practcial No.4 (Coding/Programming)/*


***PSGC***|PRACTICAL04: Write a program that finds the factorial of an inputted
number.*****/

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

int inputtedNumber,factorial;

// variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.04");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter number to find it's factorial ? ");


scanf("%d",&inputtedNumber);

printf("\n\t Factorial of [%d]",inputtedNumber);


factorial=1.0;
for(inputtedNumber=inputtedNumber;inputtedNumber>=1;inputtedNumber--)
{factorial*=inputtedNumber;}
printf(" is [%d]",factorial);

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

/************************ OUTPUT *************************************


_______________________________
This is sample Practical No.04
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter number to find it's factorial ? 6
Factorial of [6] is [720]
***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 18


XII PRACTICAL C & Access Database 2020-21

Practcial No.5 (Flow Chart- Greatest among 3 no.)


Start A

INPUT “Enter Number1? “ Test


,mgNum1 No
IF mgNum2 >
mgNum3

Yes
INPUT “Enter Number2? “ PRINT mgNum2 ”is GREATEST
,mgNum2 among all three inputted”

INPUT “Enter Number3? “ PRINT mgNum3 ”is GREATEST


,mgNum3 among all three inputted”

No Test Stop
IF mgNum1 >
mgNum2

Yes
Test No
IF mgNum1 >
mgNum3

Yes
PRINT mgNum1 ”is GREATEST
among all three inputted”

PRINT mgNum3 ”is GREATEST


among all three inputted”

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 19


XII PRACTICAL C & Access Database 2020-21

Practcial No.5 (Algorithm- Greatest among 3 no.)


Step1: BEGIN
Step2: DECLARE mgNum1,mgNum2,mgNum3 AS integer
Step3: WRITE “Enter Number1”
Step4: READ mgNum1
Step5: WRITE “Enter Number2”
Step6: READ mgNum2
Step7: WRITE “Enter Number3”
Step8: READ mgNum3
Step9: IF mgNum1> mgNum2 THEN GOTO Step10 ELSE Step14
Step10: IF mgNum1> mgNum3 THEN Step8 ELSE Step9
Step11: WRITE “number1=”,mgNum1,” is GREATEST among all
three inputted Numbers”
Step12: WRITE “number3=”,mgNum3,” is GREATEST among all
three inputted Numbers”
Step13: ENDIF rem *** eof step7 if-structure ***
Step14: IF mgNum2>mgNum3 THEN GOTO Step15 ELSE Step16
Step15: WRITE “number2=”,mgNum2,” is GREATEST among all
three inputted Numbers”
Step16: ENDIF rem *** eof step15 if-structure ***
Step17: ENDIF rem *** eof step9 if-structure ***
Step18: WRITE “number3=”,mgNum3,” is GREATEST among all
three inputted Numbers”
Step19: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 20


XII PRACTICAL C & Access Database 2020-21

Practcial No.5 (Coding/Programming)


/* ***PSGC***|PRACTICAL05:Write a program that finds out the greatest number among
three inputted numbers.*****/
#include <stdio.h>
#include <conio.h>
int mgNum1,mgNumb2,mgNum3; // variable declaration.
void main(void) // main function.
{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.05");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\t Enter Number1 ? ");
scanf("%d",&mgNum1);
printf("\n\t Enter Number2 ? ");
scanf("%d",&mgNum2);
printf("\n\t Enter Number3 ? ");
scanf("%d",&mgNumb3);

if(mgNum1>mgNum2)
{ // body of outer-most if statement.
if(mgNum1>mgNumb3)
{ // body of inner if statement.
printf("\n\t\t number1=[%d] is GREATEST among all three inputted Numbers",mgNum1);
}
else
{ // else of inner if.
printf("\n\t\t number3=[%d] is GREATEST among all three inputted Numbers",mgNum3);
}
}
else if(mgNum2>=mgNum3)
{ // else-if of outer-most if statement.
printf("\n\t\t number2=[%d] is GREATEST among all three inputted Numbers",mgNum2);
}
else
{ // else of outer-most if statement.
printf("\n\t\t number3=[%d] is GREATEST among all three inputted Numbers",mgNum3);
}

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 21


XII PRACTICAL C & Access Database 2020-21
getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.
/************************ OUTPUT *************************************
_______________________________
This is sample Practical No.05
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter number1 ? 6
Enter number2 ? 7
Enter number3 ? 5

number2=[7] is GREATEST among all three inputted Numbers


***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 22


XII PRACTICAL C & Access Database 2020-21

Practcial No.6 (Flow Chart- Calculating the Area and


Volume)
Start

Let constant PI as 3.14

INPUT “Enter Base of a


triangle?”,base

INPUT “Enter Height of a


triangle?”,height

Let areaOfTriangle =
(1.0/2.0)*base*height

INPUT “Enter radius of an


sphere?”, radius

Let volumeOfSphere = (4.0/3)


* pi * 𝒓𝒂𝒅𝒊𝒖𝒔3

PRINT “Area of Triangle ”,


areaofTriangle

PRINT “Volume of Sphere is “,


volumeOfSphere Stop

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 23


XII PRACTICAL C & Access Database 2020-21

Practcial No.6 (Algorithm- Calculating the Area and


Volume)
Step1: BEGIN
Step2: DECLARE pi AS 3.14
Step3: DECLARE areaOfTriangle, volumeOfSphere AS Real
Number
Step4: DECLARE radius,base,height AS integer
Step5: WRITE “Enter Base of a triangle? "
Step6: READ base
Step7: WRITE “Enter Height of a triangle? "
Step8: READ height
Step9: SET areaOfTriangle= (1.0/2.0)*base*height
Step10: WRITE “Enter radius of an sphere? "
Step11: READ radius
Step12: SET volumeOfSphere= (4.0/3) * pi * 𝒓𝒂𝒅𝒊𝒖𝒔3
Step13: WRITE “ Area of Triangle[base= ]”, base, “height= “,
height, “] is “, areaofTriangle
Step14: WRITE “ Volume of Sphere[radius= “, radius ,”] is “,
volumeOfSphere
Step15: READ character
Step16: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 24


XII PRACTICAL C & Access Database 2020-21

Practcial No.6 (Coding/Programming)/*


***PSGC***|PRACTICAL06:Write a program which uses arithmetic operators to calculate the
area of triangle and volume of sphere.
area of a triangle=(1/2)Base x Height
volume of sphere=(4/3 x pi x radius x radius x radius) *****/

#include <stdio.h>
#include <conio.h>
#include <math.h>

#define pi 3.14
float areaOfTriangle,volumeOfSphere; // variable declaration.
int radius,base,height;
void main(void) // main function.
{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.06");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter Base of a triangle? ");


scanf("%d",&base);

printf("\n\t Enter Height of a triangle? ");


scanf("%d",&height);

areaOfTriangle=(1.0/2.0*base*height);

printf("\n\t Enter radius of an sphere? ");


scanf("%d",&radius);

volumeOfSphere= 4.0/3*pi*pow(radius,3);

printf("\n\t Area of Triangle[base=%d height=%d] is %.2f",base,height,areaOfTriangle);


printf("\n\t Volume of Sphere[radius=%d] is %.2f",radius,volumeOfSphere);

getch(); // pause screen till any button is pressed.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 25


XII PRACTICAL C & Access Database 2020-21
} // end of-(eof) body of main function.

/************************ OUTPUT *************************************


_______________________________
This is sample Practical No.06
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Breath of a triangle? 4
Enter Height of a triangle? 6
Enter radius of an sphere? 3
Area of Triangle[base=6 height=4] is 12.00
Volume of Sphere[radius=3] is 113.04

***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 26


XII PRACTICAL C & Access Database 2020-21

Practcial No.7 (Flow Chart- Shatranjh Board)


Start A

Let mgRow=1
Let mgCol = mgCol + 1
4

5
2

No Test Let mgRow = mgRow + 1


1 For mgRow <= 8 5

Yes 1

Let mgCol=1
Stop

No Test
2 For mgCol <= 8

Yes

No Test
IF (mgRow+mgCol)
mod 2 = 0

Yes
PRINT “ “
3

PRINT “██”
3

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 27


XII PRACTICAL C & Access Database 2020-21

Practcial No.7 (Algorithm-- Shatranjh Board)


Step1: BEGIN
Step2: DECLARE mgRow,mgColumn AS integer
Step3: FOR mgRow=1 to 8 Step=1
Step4: WRITELINE
Step5: FOR mgColumn=1 to 8 Step=1
Step6: IF (mgRow+mgColumn) Mod 2= 0 THEN WRITE “ “ ELSE
WRITE ” ██”
Step7: NEXT mgColumn
Step8: NEXT mgRow
Step9: READ character
Step10: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 28


XII PRACTICAL C & Access Database 2020-21

Practcial No.7 (Coding/Programming)


/* ***PSGC***|PRACTICAL07:write a program to draw a check-board using if-else statement
and Nested for loops. *****/

#include <stdio.h>
#include <conio.h>
int mgRow,mgColumn; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.07");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.
for(mgRow=1;mgRow<=8;mgRow++)
{
printf("\n"); // printing line gap on screen.
for(mgColumn=1;mgColumn<=8;mgColumn++)
{

if((mgRow+mgColumn)%2==0)
printf(" ");
else
printf("██"); // Ascii code of █ is 219 can also be used.
} // end of for columnCounter loop.

} // end of for rowConter loop.


getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.
/************************ OUTPUT *************************************
_______________________________
This is sample Practical No.07
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
█ █ █ █
█ █ █ █
█ █ █ █
█ █ █ █
***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 29


XII PRACTICAL C & Access Database 2020-21

Practcial No.8 (Flow Chart- ASCII Code)

Start

Let mgAsciiCode=32

No Test For
Stop mgAsciiCode <=
127
Yes

PRINT “Character is
“,char(mgAsciiCode),” (code= “,
mgAsciiCode , ”)”

Let mgAsciiCode = mgAsciiCode


+1

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 30


XII PRACTICAL C & Access Database 2020-21

Practcial No.8 (Algorithm- ASCII Code)

Step1: BEGIN
Step2: DECLARE mgAsciiCode AS integer
Step3: FOR mgAsciiCode=32 to 127 Step=1
Step4: WRITE “Character is “,char(mgAsciiCode),” (code= “,
mgAsciiCode , ”)”
Step5: READ character
Step6: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 31


XII PRACTICAL C & Access Database 2020-21

Practcial No.8 (Coding/Programming)


/* ***PSGC***|PRACTICAL08:Write a program that generate characters corresponding to
ASCII codes from 32 to 127 (using any loop). *****/

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

int mgAsciiCode; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.08");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
for(mgAsciiCode=32;mgAsciiCode<=127;mgAsciiCode++)
{
printf("\tCharacter is %c(code=%d)",mgAsciiCode,mgAsciiCode);
} // end of for loop.

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

/************************ OUTPUT *************************************


_______________________________
This is sample Practical No.08
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Character is (code=32) Character is !(Code=330 . .Character is A(code=65)
Character is B(code=66)...... Character is •(code=127)

***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 32


XII PRACTICAL C & Access Database 2020-21

Practcial No.9 (Flow Chart- Printing name 10 times)

Start

INPUT “Enter your name ?


”,makName

Let numOfTimes=1

Test for YES PRINT “Your name”, makName ,


numOfTimes <= “is Printed”,numOfTimes, “
10 times”
NO

Stop Let numOfTimes =


numOfTimes+1

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 33


XII PRACTICAL C & Access Database 2020-21

Practcial No.9 (Algorithm- Print name 10 times)

Step1: BEGIN
Step2: DECLARE Dim makName(20) AS character, numOfTimes
as integer
Step3: WRITE “Enter your name ? “
Step4: READ makName
Step5: FOR numOfTimes=1 to 10 Step=1
Step6: WRITE “Your Name”, makName , “ is printed“,
numOfTimes, “ times
Step7: READ character
Step8: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 34


XII PRACTICAL C & Access Database 2020-21

Practcial No.9 (Coding/Programming)


/* ***PSGC***|PRACTICAL09:Write a program that reads your name and prints that name
10 times using scanf() and printf() statements) *****/

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

char name[20]; // variable declaration.


int numOfTimes;

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.09");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter your name ? ");


scanf("%s"makName);
for(numOfTimes=1;numOfTimes<=10;numOfTimes++)
{
printf("\n\t Your Name %s is printed %d times " ,makName, numOfTimes);
}
getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 35


XII PRACTICAL C & Access Database 2020-21
/************************ OUTPUT *************************************
_______________________________
This is sample Practical No.09
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Student name? Hasan

Enter Student age? 3

Enter height (5.4/6.0 etc)? 3.25

Enter Student gender(male/female)? male

Name of Student is Hasan


Age of Student is 3
Height of Student is 3.25
Gender of Student is male
***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 36


XII PRACTICAL C & Access Database 2020-21

Practcial No.10 (Flow Chart- Prime No. checking)


A
Start

INPUT "Enter Number to check PRINT “ Given Number


whether is PRIME OR NOT? ", “,makNum , “ is PRIME Number "
makNum

Let flag=0 PRINT ",Hence given Number”,


makNum , “ is NOT a prime
number"

Let divisor=makNum/2
Stop

Test
1 For divisor >= 2

Test Let divisor= divisor - 1


IF makNum %
divisor = 0

Let flag=1

PRINT divisor,” absolutely divide”,


makNum “

Test
IF flag = 0

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 37


XII PRACTICAL C & Access Database 2020-21

Practcial No.10 (Algorithm- Prime No. checking)


Step1: BEGIN
Step2: DECLARE makNum,flag, divisor as integer
Step3: WRITE" Enter Number to check whether is PRIME OR
NOT? "
Step4: READ makNum
Step5: flag=0
Step6: FOR divisor=makNum/2 to 2 STEP= -1
Step7: IF (makNum MOD divisor)= 0 THEN
Step8: SET flag=1
Step9: WRITE divisor,” absolutely divide”, makNum
Step10: GOTO Step 13
Step11: END IF
Step12: NEXT divisor
Step13: IF flag=0 THEN WRITE “ Given Number “,makNum , “ is
PRIME Number " ELSE WRITE ",Hence given Number”,
makNum , “ is NOT a prime number"
Step14: ENDIF
Step15: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 38


XII PRACTICAL C & Access Database 2020-21

Practcial No.10 (Coding/Programming)


/* ***PSGC***|PRACTICAL10:Write a program that input a number and then check it whether
it is prime or not . *****/

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

int number,divisor,flag; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.10");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter Number to check whether is PRIME OR NOT? ");


scanf("%d",&number);
flag=0;

for(divisor=number/2;divisor>=2;divisor--)
{
if(number%divisor==0) {flag=1;printf("%d absolutely divide %d",divisor,number); break;}
}

if(flag==0) printf("\n\t Given Number %d is PRIME number",number);


else
printf(",Hence given Number %d is NOT a prime number",number);

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

/************************ OUTPUT *************************************


_______________________________
This is sample Practical No.10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Number to check wheter its PRIME OR NOT? 7
Given Number 7 is PRIME number

***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 39


XII PRACTICAL C & Access Database 2020-21

Practcial No.11 (Flow Chart)


Start

INPUT “Enter your name ?


”,mgName

INPUT “Enter your favorite


English alphabet?
”,makAlphabet

INPUT “Enter your age (5-100


etc)?”,age

INPUT “Enter your height


(5.4/6.0 etc)?”,height

PRINT “Your Name is”,mgName

PRINT “You like English


alphabet? ”,makAlphabet

PRINT “your are “,age,” years


old”

PRINT “and “,height ,” feet


tall.” Start

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 40


XII PRACTICAL C & Access Database 2020-21

Practcial No.11 (Algorithm)

Step1: BEGIN
Step2: DECLARE mgName AS String, makAlphabet AS Character,
age AS integer, height AS Real number
Step3: WRITE “Enter your name? "
Step4: READ mgName
Step5: WRITE “Enter your favorite English alphabet?”
Step6: READ makAlphabet
Step7: WRITE “Enter your age (5-100 etc)? "
Step8: READ age
Step9: WRITE ”Enter your height (5.4/6.0 etc)? "
Step10: READ height
Step11: WRITE “Your Name is ”,mgName
Step12: WRITE “you like English alphabet “,makAlphabet
Step13: WRITE ”you are “,age, “ years old”
Step14: WRITE “ and “,height, “ feet tall."
Step15: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 41


XII PRACTICAL C & Access Database 2020-21

Practcial No.11 (Coding/Programming)


/* ***PSGC***|PRACTICAL11:Write a program which print a text of four lines consisting
of characters, integers value and floating point value using printf() statement and escape
sequences. . *****/

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

char mgName[30],makAlphabet; // variable declaration.


unsigned int age;
float height;

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.11");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~");

printf("\n\t Enter your name? ");


gets(mgName);
printf("\n\t Enter your favorite English alphabet? ");
makAlphabet=getchar();
printf("\n\t Enter your age (5-100 etc)? ");
scanf("%u",&age);
printf("\n\t Enter your height (5.4/6.0 etc)? ");
scanf("%f",&height);

printf("\n\t Your Name is %s,",mgName);


printf("\n\t you like English alphabet %c,",makAlphabet);
printf("\n\t you are %u years old,",age);
printf("\n\t and %.2f feet tall.",height);

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 42


XII PRACTICAL C & Access Database 2020-21
/************************ OUTPUT *************************************
_______________________________
This is sample Practical No.11
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter your name? Muhammad Hasan Khan Ghori

Enter your favorite English alphabet? M

Enter your age (3-100 etc)? 3

Enter your height (5.4/6.0 etc)? 3.25

Your Name is Muhammad Hasan Khan Ghori,


you like English alphabet M,
you are 3 years old,
and 3.25 feet tall.
***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 43


XII PRACTICAL C & Access Database 2020-21

Practcial No.12 (Flow Chart- Switch statement)


Start

Let makRow=1
3

Let makCol = makCol + 1


5
4
Test
1 For makRow <= 8 2
No
Let makRow = makRow + 1
5
Yes
Let makCol=1
1

4 Stop

No Test
2 For makCol <= 8

Yes
Yes
Test case
No
(makRow+makCol)
mod 2 = 0

Yes
PRINT “ “
3

PRINT “██”
3

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 44


XII PRACTICAL C & Access Database 2020-21

Practcial No.12 (Algorithm- Switch Statement)


Step1: BEGIN
Step2: DECLARE makRow,makCol,result AS integer
Step3: FOR makRow=1 TO 8 STEP=+1
Step4: WRITELINE
Step5: FOR makCol=1 TO 8 STEP=+1
Step6: SET result=(makRow+makCol) MOD 2
Step7: IF result= 0 THEN WRITE “ “ ELSE WRITE ” ██”
Step8: END IF
Step9: NEXT makCol
Step10: NEXT makRow
Step11: READ character
Step12: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 45


XII PRACTICAL C & Access Database 2020-21

Practcial No.12 (Coding/Programming)


/* ***PSGC***|PRACTICAL12:Write a program ,which uses Switch and break statement
.*****/

#include <stdio.h>
#include <conio.h>
int makRow,makCol,result; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.12");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.
for(makRow=1;makRow<=8;makRow++)
{
printf("\n"); // printing line gap on screen.
for(makCol=1;makCol<=8;makCol++)
{
result=(makRow+makCol)%2;

switch(result)
{ // start of switch(result) body.
case 0:printf(" ");break;
default:printf("%c%c",219,219); // Ascii code of █ is 219 can also be used.
} // end of switch(result)-statement .

} // end of for column loop.


} // end of for row loop.

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

/************************ OUTPUT *************************************


_______________________________
This is sample Practical No.12
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
█ █ █ █
█ █ █ █
█ █ █ █
█ █ █ █

***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 46


XII PRACTICAL C & Access Database 2020-21

Practcial No.13 (Flow Chart- Pattern Printing)

Start

Let makRow=1

Test No
For makRow <=5 Stop

Yes

Let makCol=1

No Test
For makCol <= 2
makRow

Yes
PRINT “*“ Let makCol = makCol + 1

Let makRow = makRow + 1


1
2

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 47


XII PRACTICAL C & Access Database 2020-21

Practcial No.13 (Algorithm- Pattern Printing)

Step1: BEGIN
Step2: DECLARE makRow,makCol,result AS integer
Step3: FOR makRow=1 TO 5 STEP=+1
Step4: WRITELINE
Step5: FOR makCol=1 TO makRow STEP=+1
Step6: WRITE “ * “
Step7: NEXT makCol
Step8: NEXT makRow
Step9: READ character
Step10: END

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 48


XII PRACTICAL C & Access Database 2020-21

Practcial No.13 (Coding/Programming)


/* ***PSGC***|PRACTICAL13:Write a program using nested for loop to print the following
output
*
**
***
****
*****
**********************************************/

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

int makRow,makCol;
; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.13");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.

for(makRow=1;makCol<=5;makRow++)
{
printf("\n\t\t\t"); // printing line and tab gap on screen.
for(makCol=1;makCol<=makRow;makCol++)
{
printf(" *");
} // end of for makCol loop.
} // end of for makRow loop.
getch(); // pause screen till any button is pressed.
} // end of-(eof) body of main function.
/************************ OUTPUT *************************************
_______________________________
This is sample Practical No.13
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
**
***
****
*****
***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 49


XII PRACTICAL C & Access Database 2020-21

Practcial No.14 (Flow Chart- 2 Nos. SumFunction)

Start

INPUT “Enter number1 ?


”,number1

INPUT “Enter number2 ?


”,number2 Flow chart of Sub-process

makSum1(number1,number2)

Calling Sub-process
makSum1(number1 ,
number2)

Stop Start

Let digit1 = number1

Let digit2 = number2

PRINT ““Sum of “ , digit1 , “+”


, digit2 , “= “,(digit1+digit2)1,
“+”,digit2, “=”,(digit1+digit2)

Stop

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 50


XII PRACTICAL C & Access Database 2020-21

Practcial No.14 (Algorithm- 2 Nos. SumFunction)


Step1: BEGIN
Step2: DECLARE makSum1(integer,integer) AS integer
Step3: DECLARE number1,number2 AS integer
Step4: WRITE “Enter Number1 ?”
Step5: READ number1
Step6: WRITE “Enter Number2 ?”
Step7: READ number2
Step8: Call makSum1(number1,number2)
Step9: READ character
Step10: END

Step11: BEGIN makSum1(digit1 AS integer,digit2 AS integer)


Step12: WRITE “Sum of “ , digit1 , “+” , digit2 , “= “,(digit1+digit2)
Step13: END makSum1

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 51


XII PRACTICAL C & Access Database 2020-21

Practcial No.14 (Coding/Programming)


/* ***PSGC***|PRACTICAL14:Write a program that input any two number and then pass
these numbers as arguments to function sum1 and then print their sum.
****************************************************************/

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

void sum1(int,int); // function sum1 declaration.

int number1,number2; // variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.14");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.

printf("\n\t Enter Number1 ? ");


scanf("%d",&number1);

printf("\n\t Enter Number2 ? ");


scanf("%d",&number2);

sum1(number1,number2); // calling sum1 function & passing number1 & number2 to it.

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

// below is the definition of function sum1.


void sum1(int digit1,int digit2)
{ // start of sum1 function body.
printf("\n\t Sum of %d + %d = %d",digit1,digit2,(digit1+digit2));
return;
} // end of sum1 function body.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 52


XII PRACTICAL C & Access Database 2020-21
/************************ OUTPUT *************************************
_______________________________
This is sample Practical No.14
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Number1 ? 7

Enter Number2 ? 6

Sum of 7 + 6 = 13
***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 53


XII PRACTICAL C & Access Database 2020-21

Practcial No.15 (Flow Chart- Payroll of Emplyee)


Flow chart of Sub-process
Start
Real percentageCalculator (amount
as Real, percentage as Integer)

Input “Enter Basic Pay?


”,mgBasicPay
Start

Let medicalAllowance =
RETURN percentageCalculator(mgB
(amount*percent/100.0) AS asicPay, 25)
Real number

Let conveyanceAllowance=
percentageCalculator(mgB
asicPay, 20)
Stop

Let houseRent =
percentageCalculator(mgB
asicPay, 45)

Let gpFund =
percentageCalculator(mgB
asicPay, 7)

Let grossPay = mgBasicPay+


medicalAllowance +
ConveyanceAllowance + houseRent

Let netPay = grossPay - gpFund

AAA

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 54


XII PRACTICAL C & Access Database 2020-21

AAA

PRINT “ BASIC PAY=


“,mgBasicPay

PRINT “ MEDICAL ALLOWANCE=


,medicalAllowance

PRINT “Conveyance Allowance=


“,conveyanceAllowance

PRINT “ House Rent=


“,houseRent

PRINT “ Gross Pay=


“,grossPay

PRINT “ Deduction of GPFund=


“,gpFund

PRINT “ Net Pay= “,netPay

Stop

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 55


XII PRACTICAL C & Access Database 2020-21

Practcial No.15 (Algorithm- Payroll of Employee)


Step1: BEGIN
Step2: DECLARE percentageCalculator(Realnumber, integer) AS
Real Number
Step3: DECLARE mgBasicPay, medicalAllowance,
conveyanceAllowance, houseRent, gpFund, grossPay, netPay AS
Real Number
Step4: WRITE “Enter Basic Pay? “
Step5: READ mgBasicPay
Step6: SET medicalAllowance=CALL
percentageCalculator(mgBasicPay,25)
Step7: SET conveyanceAllowance = CALL
percentageCalculator(mgBasicPay,20)
Step8: SET houseRent = CALL percentageCalculator(mgBasicPay,45)
Step9: SET gpFund = CALL percentageCalculator(mgBasicPay,7)
Step10: SET grossPay= mgBasicPay + medicalAllowance +
conveyanceAllowance + houseRent
Step11: SET netPay= grossPay-gpFund
Step12: WRITE “ BASIC PAY= “,mgBasicPay
Step13: WRITE “ MEDICAL ALLOWANCE= “,medicalAllowance
Step14: WRITE “ Conveyance Allowance= “,conveyanceAllowance
Step15: WRITE “ House Rent= “,houseRent
Step16: WRITE “ Gross Pay= “,grossPay
Step17: WRITE “ Deduction of GPFund= “,gpFund
Step18: WRITE “ Net Pay= “,netPay
Step19: READ character
Step20: END
Step21: BEGIN FUNCTION percentageCalculator(amount AS Real
Number,percent AS integer)
Step22: RETURN (amount*percent/100.0)
Step23: END FUNCTION percentageCalculator

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 56


XII PRACTICAL C & Access Database 2020-21

Practcial No.15 (Coding/Programming)


/* ***PSGC***|PRACTICAL15:Write a program to calculate a pay roll of employees .Read
the Basic pay from key board .Calculate medical allowance as 25% of basic pay , conveyance

allowance as 20% and house rent 45 % of basic pay and deduction of GP fund 7% of basic
pay

. Calculate gross pay and net pay .


****************************************************************/

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

float percentageCalculator(float,int); // function sum1 declaration.

float mgBasicPay,medicalAllowance,conveyanceAllowance,houseRent,gpFund,grossPay,netPay;

// variable declaration.

void main(void) // main function.


{ // start of-(sof) body of main function.
clrscr();
// below code is for showing heading of the output
printf("\n\t\t______________________________");
printf("\n\t\tThis is sample Practical No.15");
printf("\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n"); // printf two line gap on screen.

printf("\n\t Enter Basic Pay ? ");


scanf("%f",&mgBasicPay);

// calling percentageCalculator function & passing values to it.

medicalAllowance=percentageCalculator(mgBasicPay,25);
conveyanceAllowance=percentageCalculator(mgBasicPay,20);
houseRent=percentageCalculator(mgBasicPay,45);
gpFund=percentageCalculator(mgBasicPay,7);

grossPay=mgBasicPay+medicalAllowance+conveyanceAllowance+houseRent;
netPay=grossPay-gpFund;

printf("\n\t BASIC PAY= %.2f",mgBasicPay);


printf("\n\t MEDICAL ALLOWANCE= %.2f",medicalAllowance);
printf("\n\t Conveyance Allowance= %.2f",conveyanceAllowance);

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 57


XII PRACTICAL C & Access Database 2020-21
printf("\n\t House Rent= %.2f",houseRent);

printf("\n\t Gross Pay= %.2f",grossPay);


printf("\n\t Deduction of GPFund= %.2f",gpFund);

printf("\n\t Net Pay= %.2f",netPay);

getch(); // pause screen till any button is pressed.


} // end of-(eof) body of main function.

// below is the definition of percentageCalculator function.


float percentageCalculator(float amount,int percent)
{ // start of function body.
return (amount*percent/100.0);
} // end of function body.

/************************ OUTPUT *************************************


_______________________________
This is sample Practical No.15
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Enter Basic Pay ? 1000

BASIC PAY= 1000.00


MEDICAL ALLOWANCE= 250.00
Conveyance Allowance= 200.00
House Rent= 450.00
Gross Pay= 1900.00
Deduction of GPFund= 70.00
Net Pay= 1830.00
***********************************************************************/

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 58


XII PRACTICAL C & Access Database 2020-21

Part-2 Databases

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 59


XII PRACTICAL C & Access Database 2020-21

Practical No.1

Object Write a procedure to create a table Teacher having the


following fields

FacultyId, TeacherName, Designation, Department.

Queries
1. Assign primary key to a suitable column.
[Link] 5 records
3. Dispay all records having same Department
4. List all the records with designation Lecturer.

Procedure
Switching on Computer
1- Switch on your computer. Wait till the operation system “Windows” let you give access to
interact with the computer.

Searching and Opening MS-Access


2-With the help of mouse click “Start” Icon, generally present at bottom left side of the
computer screen‫۔‬

3-Use Mouse click “Search Bar”, type “Microsoft Office Access” in it with the help of computer
keyboard to search and open MS-Access.

Creating Database
4-Point Mouse Cursor to Blank Database, it will be highlighted then click it with mouse.

5- New panel at right hand side will be open, point your mouse cursor to the file name location,
type new name “TeacherDatabase” there then click “Create” button.

Creating & Renaming Table


6-Another big new panel at right hand side will be open, point your mouse cursor to “Table1:
Table” icon, it will be highlighted then right click it, with the mouse. A “drop-down menu” will
be open, click second option “Design View” from it.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 60


XII PRACTICAL C & Access Database 2020-21
7- Now “Save As” panel will be open, give new name “Teacher” in the text box to Save
“Table1” as “Teacher”, then press “ok” Button.

8-Type in the “Field Name” text value “FacultyID”.

9- Use mouse to point the cell below “Data Type”, select there “Auto Number” from the
available “combo box” option list.
10- Use mouse to point the next cell present under “Description” heading, type the description
whatever you want to write for your future reference or let it remain empty.

11- Repeat above steps till all the remaining fields (TeacherName, Designation, Department)
with “data types” and “description” are properly typed into the corresponding cell of Database
Design Window. Always use “Text” data type for fields like [Name, Address, Contact, Email
etc.], “AutoNumber” for automatic assignment of numbers. “Numeric” for fields on which
calculation are performed, “Currency” for fields like [wages, salary], “Date” for fields which are
supposed to store dates, “Hyperlink” for fields holding [websites / urls etc.], “OLE Object” for
picture, photographs, “Yes/No” for status showing field, “Attachment” for external files,
“Memo” for descriptive fields.”Lookup Wizard” for foreign fields from other tables of the
database.

12-
Requirement#1- Assigning Primary Key to the suitable field i.e “FacultyId”
which can be capable of identifying each record uniquely. If it is already assigned by computer
then no need to re-assign it.

13-Save the Table once again to update changes.

14
Requirement#2- Entering Five(5) Records

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 61


XII PRACTICAL C & Access Database 2020-21
14-Now double click “Teacher” table to open it. Enter valid data into it. Use mouse to toggle
b/w the fields of each record. Continue adding the record until you complete entering desired
records. After it, close & finish record entry.

Queries Design
15-With the help of mouse click “Create”, then point and left click “Query Design”.

17- “Show table” panel will be open, select ” Table” tab from “Table/Query/Both”.
Point and double left click the desired tables from available list of tables, to add these
tables then left click “cross/close” present on top-right hand side of the panel, to close
it.

18- Select field name from the available list of “combo-box”, which you want to display
or manipulate. Table name of that particular field will automatically be added after your
selection of field. Mention the criteria if you want. Uncheck the ”CheckBox” if you don’t
want to display this field.

19- Do repeat above step number 19 for each and every field, you want more to display
or manipulate until you complete all desired field entries

20- Now in the “criteria” cell of field “Department” enter the contents “Computer
Science” to create the query of “all records having same department” and then Left click
the “Cross/Close” button to close the Query Panel, left click “Yes” Button to save the
Query1 with the new name “TeacherQuery1”, again left click “Ok” Button. You can
save query with your desired name as well.

21- Repeat from above step number 17 to 21 for creating remaining queries, just
remove the contents of criteria cell, as per your requirement i.e. remove the contents

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 62


XII PRACTICAL C & Access Database 2020-21
of field “Department” and enter the contents “Lecturer” in the criteria cell of
“Designation” field, to “list all the records with designation (Lecturer)”.

Obtaining Query Results


22-Double click any query to display its result, if there is a need of passing any value
then just type-in the value you want to pass into the panel that appears before you.

Output

Requirement#3. Teachers of same Department.

Requirement#4. Teachers of same Designation.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 63


XII PRACTICAL C & Access Database 2020-21

Practical No.2

Object Write a procedure to create a table Student having the


following fields

StudentId, StudentName, Address, Cellno

Queries
1. Assign primary key to a suitable column.
[Link] 5 records
3. Dispay all records
4. Search record with StudentID.

Procedure

Switching on Computer
1- Switch on your computer. Wait till the operation system “Windows” let you give access to
interact with the computer.

Searching and Opening MS-Access


2-With the help of mouse click “Start” Icon, generally present at bottom left side of the
computer screen‫۔‬

3-Use Mouse click “Search Bar”, type “Microsoft Office Access” in it with the help of computer
keyboard to search and open MS-Access.

Creating Database
4-Point Mouse Cursor to Blank Database, it will be highlighted then click it with mouse.

5- New panel at right hand side will be open, point your mouse cursor to the file name location,
type new name “StudentDatabase” there then click “Create” button.

Creating & Renaming Table


6-Another big new panel at right hand side will be open, point your mouse cursor to “Table1:
Table” icon, it will be highlighted then right click it, with the mouse. A “drop-down menu” will
be open, click second option “Design View” from it.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 64


XII PRACTICAL C & Access Database 2020-21
7- Now “Save As” panel will be open, give new name “Student” in the text box to Save
“Table1” as “Student”, then press “ok” Button.

8-Type in the “Field Name” text value “StudentId”.

9- Use mouse to point the cell below “Data Type”, select there “Auto Number” from the
available “combo box” option list.
10- Use mouse to point the next cell present under “Description” heading, type the description
whatever you want to write for your future reference or let it remain empty.

11- Repeat above steps till all the remaining fields (StudentName, Address, Cellno) with “data
types” and “description” are properly typed into the corresponding cell of Database Design
Window. Always use “Text” data type for fields like [Name, Address, Contact, Email etc.],
“AutoNumber” for automatic assignment of numbers. “Numeric” for fields on which
calculation are performed, “Currency” for fields like [wages, salary], “Date” for fields which are
supposed to store dates, “Hyperlink” for fields holding [websites / urls etc.], “OLE Object” for
picture, photographs, “Yes/No” for status showing field, “Attachment” for external files,
“Memo” for descriptive fields.”Lookup Wizard” for foreign fields from other tables of the
database.
12-
Requirement#1- Assigning Primary Key to the suitable field i.e “StudentId”
which can be capable of identifying each record uniquely. If it is already assigned by computer
then no need to re-assign it.

13-Save the Table once again to update changes.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 65


XII PRACTICAL C & Access Database 2020-21

Requirement#2- Entering Five(5) Records


14-Now double click “Student” table to open it. Enter valid data into it. Use mouse to toggle
b/w the fields of each record. Continue adding the record until you complete entering desired
records. After it, close & finish record entry.

Queries Design
15-With the help of mouse click “Create”, then point and left click “Query Design”.

17- “Show table” panel will be open, select ” Table” tab from “Table/Query/Both”.
Point and double left click the desired tables from available list of tables, to add these
tables then left click “cross/close” present on top-right hand side of the panel, to close
it.

18- Select field name from the available list of “combo-box”, which you want to display
or manipulate. Table name of that particular field will automatically be added after your
selection of field. Mention the criteria if you want. Uncheck the ”CheckBox” if you don’t
want to display this field.

19- Do repeat above step number 19 for each and every field, you want more to display
or manipulate until you complete all desired field entries

20- Now in the “criteria” cell of field “StudentId” enter the contents “[Enter Student
Id?]” to create the query of “Showing student record by Student Id” and then Left click
the “Cross/Close” button to close the Query Panel, left click “Yes” Button to save the
Query1 with the new name “Student By ID”, again left click “Ok” Button. You can save
query with your desired name as well.

21- Repeat from above step number 17 to 21 for creating remaining queries, just
remove/change the contents of criteria cell, as per your requirement.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 66


XII PRACTICAL C & Access Database 2020-21

Obtaining Query Results


22-Double click any query to display its result, if there is a need of passing any value
then just type-in the value you want to pass into the panel that appears before you.

Output
Requirement#3- Showing all Five(5) Records

Requirement#4- Showing Record by Student Id

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 67


XII PRACTICAL C & Access Database 2020-21

Practical No.3

Object Write a procedure to create a table Students having the


following fields

StudentId, Name, Class, Group, Gender.

Queries
1. Assign primary key to StudentId.
[Link] 5 records
3. Display all records of Female students
4. List all the records of students

Procedure

Switching on Computer
1- Switch on your computer. Wait till the operation system “Windows” let you give access to
interact with the computer.

Searching and Opening MS-Access


2-With the help of mouse click “Start” Icon, generally present at bottom left side of the
computer screen‫۔‬

3-Use Mouse click “Search Bar”, type “Microsoft Office Access” in it with the help of computer
keyboard to search and open MS-Access.

Creating Database
4-Point Mouse Cursor to Blank Database, it will be highlighted then click it with mouse.

5- New panel at right hand side will be open, point your mouse cursor to the file name location,
type new name “StudentsDatabase” there then click “Create” button.

Creating & Renaming Table


6-Another big new panel at right hand side will be open, point your mouse cursor to “Table1:
Table” icon, it will be highlighted then right click it, with the mouse. A “drop-down menu” will
be open, click second option “Design View” from it.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 68


XII PRACTICAL C & Access Database 2020-21
7- Now “Save As” panel will be open, give new name “Students” in the text box to Save
“Table1” as “Students”, then press “ok” Button.

8-Type in the “Field Name” text value “StudentID”.

9- Use mouse to point the cell below “Data Type”, select there “Auto Number” from the
available “combo box” option list.
10- Use mouse to point the next cell present under “Description” heading, type the description
whatever you want to write for your future reference or let it remain empty.

11- Repeat above steps till all the remaining fields (StudentName, Class, Group, Gender) with
“data types” and “description” are properly typed into the corresponding cell of Database
Design Window. Always use “Text” data type for fields like [Name, Address, Contact, Email
etc.], “AutoNumber” for automatic assignment of numbers. “Numeric” for fields on which
calculation are performed, “Currency” for fields like [wages, salary], “Date” for fields which are
supposed to store dates, “Hyperlink” for fields holding [websites / urls etc.], “OLE Object” for
picture, photographs, “Yes/No” for status showing field, “Attachment” for external files,
“Memo” for descriptive fields.”Lookup Wizard” for foreign fields from other tables of the
database.
12-
Requirement#1- Assigning Primary Key to the suitable field i.e “StudentID”
which can be capable of identifying each record uniquely. If it is already assigned by computer
then no need to re-assign it.

13-Save the Table once again to update changes.

Requirement#2- Entering Five(5) Records


14-Now double click “Students” table to open it. Enter valid data into it. Use mouse to toggle
b/w the fields of each record. Continue adding the record until you complete entering desired
records. After it, close & finish record entry.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 69


XII PRACTICAL C & Access Database 2020-21

Queries Design
15-With the help of mouse click “Create”, then point and left click “Query Design”.

17- “Show table” panel will be open, select ” Table” tab from “Table/Query/Both”.
Point and double left click the desired tables from available list of tables, to add these
tables then left click “cross/close” present on top-right hand side of the panel, to close
it.

18- Select field name from the available list of “combo-box”, which you want to display
or manipulate. Table name of that particular field will automatically be added after your
selection of field. Mention the criteria if you want. Uncheck the ”CheckBox” if you don’t
want to display this field.

19- Do repeat above step number 19 for each and every field, you want more to display
or manipulate until you complete all desired field entries

20- Now in the “criteria” cell of field “Gender” enter the contents “Female” to create
the query of “all female records” and then Left click the “Cross/Close” button to close
the Query Panel, left click “Yes” Button to save the Query1 with the new name
“FemaleStudents”, again left click “Ok” Button. You can save query with your desired
name as well.

21- Repeat from above step number 17 to 21 for creating remaining queries, just
remove/change the contents of criteria cell, as per your requirement.

Obtaining Query Results


22-Double click any query to display its result, if there is a need of passing any value
then just type-in the value you want to pass into the panel that appears before you.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 70


XII PRACTICAL C & Access Database 2020-21

Output

Requirement#3- Showing all records of female students

Requirement#4- Showing all Five(5) Records

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 71


XII PRACTICAL C & Access Database 2020-21

Practical No.4

Object Write a procedure to create a table MyBank having the


following fields

AccountNo, AccountName,Credit, Debit.

Queries
1. Assign primary key to a suitable column.
[Link] 5 records
3. Add a column Balance
4. Update the column Balance.

Procedure

Switching on Computer
1- Switch on your computer. Wait till the operation system “Windows” let you give access to
interact with the computer.

Searching and Opening MS-Access


2-With the help of mouse click “Start” Icon, generally present at bottom left side of the
computer screen‫۔‬

3-Use Mouse click “Search Bar”, type “Microsoft Office Access” in it with the help of computer
keyboard to search and open MS-Access.

Creating Database
4-Point Mouse Cursor to Blank Database, it will be highlighted then click it with mouse.

5- New panel at right hand side will be open, point your mouse cursor to the file name location,
type new name “MyBankDatabase” there then click “Create” button.

Creating & Renaming Table


6-Another big new panel at right hand side will be open, point your mouse cursor to “Table1:
Table” icon, it will be highlighted then right click it, with the mouse. A “drop-down menu” will
be open, click second option “Design View” from it.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 72


XII PRACTICAL C & Access Database 2020-21
7- Now “Save As” panel will be open, give new name “MyBank” in the text box to Save
“Table1” as “MyBank”, then press “ok” Button.

8-Type in the “Field Name” text value “AccountNo”.

9- Use mouse to point the cell below “Data Type”, select there “Auto Number” from the
available “combo box” option list.
10- Use mouse to point the next cell present under “Description” heading, type the description
whatever you want to write for your future reference or let it remain empty.

11- Repeat above steps till all the remaining fields (AccountName, Credit, Debit) with “data
types” and “description” are properly typed into the corresponding cell of Database Design
Window. Always use “Text” data type for fields like [Name, Address, Contact, Email etc.],
“AutoNumber” for automatic assignment of numbers. “Numeric” for fields on which
calculation are performed, “Currency” for fields like [wages, salary], “Date” for fields which are
supposed to store dates, “Hyperlink” for fields holding [websites / urls etc.], “OLE Object” for
picture, photographs, “Yes/No” for status showing field, “Attachment” for external files,
“Memo” for descriptive fields.”Lookup Wizard” for foreign fields from other tables of the
database.
12-
Requirement#1- Assigning Primary Key to the suitable field i.e “AccountNo”
which can be capable of identifying each record uniquely. If it is already assigned by computer
then no need to re-assign it.

13-Save the Table once again to update changes.

Requirement#2- Entering Five(5) Records


14-Now double click “MyBank” table to open it. Enter valid data into it. Use mouse to toggle
b/w the fields of each record. Continue adding the record until you complete entering desired
records. After it, close & finish record entry.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 73


XII PRACTICAL C & Access Database 2020-21

Queries Design
15-With the help of mouse click “Create”, then point and left click “Query Design”.

17- “Show table” panel will be open, select ” Table” tab from “Table/Query/Both”.
Point and double left click the desired tables from available list of tables, to add these
tables then left click “cross/close” present on top-right hand side of the panel, to close
it.

18- Select field name from the available list of “combo-box”, which you want to display
or manipulate. Table name of that particular field will automatically be added after your
selection of field. Mention the criteria if you want. Uncheck the ”CheckBox” if you don’t
want to display this field.

19- Do repeat above step number 19 for each and every field, you want more to display
or manipulate until you complete all desired field entries

20- Now add new column “Balance” in the query “MyBank Query” in “design view”.
Write like this “Balance:[Credit]*[Debit]” in the Field corresponding cell to make it
calculated field to create the query of “all records show balance” and then Left click the
“Cross/Close” button to close the Query Panel, left click “Yes” Button to save the
Query1 with the new name “MyBank Query”, again left click “Ok” Button. You can save
query with your desired name as well.

21- Repeat from above step number 17 to 21 for creating remaining queries, just
remove the contents of criteria cell, as per your requirement.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 74


XII PRACTICAL C & Access Database 2020-21

Obtaining Query Results


22-Double click any query to display its result, if there is a need of passing any value
then just type-in the value you want to pass into the panel that appears before you.

Output
Requirement#3- Inserting Balance Column

Requirement#4- Updating Balance Column

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 75


XII PRACTICAL C & Access Database 2020-21

Practical No.5

Object Write a procedure to create a table Library having the


following fields

BookId, Name, Reference or Lending, BookIssued.

Queries
1. Assign primary key to a suitable column.
[Link] 5 records
3. Dispay all books which are not for lending
4. Find list of books issued.

Procedure

Switching on Computer
1- Switch on your computer. Wait till the operation system “Windows” let you give access to
interact with the computer.

Searching and Opening MS-Access


2-With the help of mouse click “Start” Icon, generally present at bottom left side of the
computer screen‫۔‬

3-Use Mouse click “Search Bar”, type “Microsoft Office Access” in it with the help of computer
keyboard to search and open MS-Access.

Creating Database
4-Point Mouse Cursor to Blank Database, it will be highlighted then click it with mouse.

5- New panel at right hand side will be open, point your mouse cursor to the file name location,
type new name “LibraryDatabase” there then click “Create” button.

Creating & Renaming Table


6-Another big new panel at right hand side will be open, point your mouse cursor to “Table1:
Table” icon, it will be highlighted then right click it, with the mouse. A “drop-down menu” will
be open, click second option “Design View” from it.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 76


XII PRACTICAL C & Access Database 2020-21
7- Now “Save As” panel will be open, give new name “Library” in the text box to Save “Table1”
as “Library”, then press “ok” Button.

8-Type in the “Field Name” text value “BookId”.

9- Use mouse to point the cell below “Data Type”, select there “Auto Number” from the
available “combo box” option list.
10- Use mouse to point the next cell present under “Description” heading, type the description
whatever you want to write for your future reference or let it remain empty.

11- Repeat above steps till all the remaining fields (BookName, Reference, Issued) with “data
types” and “description” are properly typed into the corresponding cell of Database Design
Window. Always use “Text” data type for fields like [Name, Address, Contact, Email etc.],
“AutoNumber” for automatic assignment of numbers. “Numeric” for fields on which
calculation are performed, “Currency” for fields like [wages, salary], “Date” for fields which are
supposed to store dates, “Hyperlink” for fields holding [websites / urls etc.], “OLE Object” for
picture, photographs, “Yes/No” for status showing field, “Attachment” for external files,
“Memo” for descriptive fields.”Lookup Wizard” for foreign fields from other tables of the
database.
12-
Requirement#1- Assigning Primary Key to the suitable field i.e “BookId” which
can be capable of identifying each record uniquely. If it is already assigned by computer then no
need to re-assign it.

13-Save the Table once again to update changes.

Requirement#2- Entering Five(05) Records


14-Now double click “Library” table to open it. Enter valid data into it. Use mouse to toggle b/w
the fields of each record. Continue adding the record until you complete entering desired
records. After it, close & finish record entry.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 77


XII PRACTICAL C & Access Database 2020-21

Queries Design
15-With the help of mouse click “Create”, then point and left click “Query Design”.

17- “Show table” panel will be open, select ” Table” tab from “Table/Query/Both”.
Point and double left click the desired tables from available list of tables, to add these
tables then left click “cross/close” present on top-right hand side of the panel, to close
it.

18- Select field name from the available list of “combo-box”, which you want to display
or manipulate. Table name of that particular field will automatically be added after your
selection of field. Mention the criteria if you want. Uncheck the ”CheckBox” if you don’t
want to display this field.

19- Do repeat above step number 19 for each and every field, you want more to display
or manipulate until you complete all desired field entries

20- Now in the “criteria” cell of field “Reference” enter the contents “Yes” to create the
query of “all books not for lending (Reference Books)” and then Left click the
“Cross/Close” button to close the Query Panel, left click “Yes” Button to save the
Query1 with the new name “Reference Books(Not for Lending)”, again left click “Ok”
Button. You can save query with your desired name as well.

21- Repeat from above step number 17 to 21 for creating remaining queries, just
remove/change the contents of criteria cell, as per your requirement.

Obtaining Query Results


22-Double click any query to display its result, if there is a need of passing any value
then just type-in the value you want to pass into the panel that appears before you.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 78


XII PRACTICAL C & Access Database 2020-21

Output

Requirement# 3- Showing Reference Books which are not for


lending

Requirement#4- List of issued Books

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 79


XII PRACTICAL C & Access Database 2020-21

Practical No.6

Object Write a procedure to create a table Employees having the


following fields

EmployeeId, EmployeeName, Address, Postcode, DateHired,


Wages.

Queries
1. Assign primary key to a suitable column.
[Link] 5 records
3. Display particular record by EmployeeId
4. Display those records who have the same Address.

Procedure

Switching on Computer
1- Switch on your computer. Wait till the operation system “Windows” let you give access to
interact with the computer.

Searching and Opening MS-Access


2-With the help of mouse click “Start” Icon, generally present at bottom left side of the
computer screen‫۔‬

3-Use Mouse click “Search Bar”, type “Microsoft Office Access” in it with the help of computer
keyboard to search and open MS-Access.

Creating Database
4-Point Mouse Cursor to Blank Database, it will be highlighted then click it with mouse.

5- New panel at right hand side will be open, point your mouse cursor to the file name location,
type new name “EmployeeDatabase” there then click “Create” button.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 80


XII PRACTICAL C & Access Database 2020-21

Creating & Renaming Table


6-Another big new panel at right hand side will be open, point your mouse cursor to “Table1:
Table” icon, it will be highlighted then right click it, with the mouse. A “drop-down menu” will
be open, click second option “Design View” from it.
7- Now “Save As” panel will be open, give new name “Employee” in the text box to Save
“Table1” as “Employee”, then press “ok” Button.

8-Type in the “Field Name” text value “EmployeeID”.

9- Use mouse to point the cell below “Data Type”, select there “Auto Number” from the
available “combo box” option list.
10- Use mouse to point the next cell present under “Description” heading, type the description
whatever you want to write for your future reference or let it remain empty.

11- Repeat above steps till all the remaining fields (EmployeeName, Address, Postcode,
DateHired) with “data types” and “description” are properly typed into the corresponding cell
of Database Design Window. Always use “Text” data type for fields like [Name, Address,
Contact, Email etc.], “AutoNumber” for automatic assignment of numbers. “Numeric” for fields
on which calculation are performed, “Currency” for fields like [wages, salary], “Date” for fields
which are supposed to store dates, “Hyperlink” for fields holding [websites / urls etc.], “OLE
Object” for picture, photographs, “Yes/No” for status showing field, “Attachment” for external
files, “Memo” for descriptive fields.”Lookup Wizard” for foreign fields from other tables of the
database.
12-
Requirement#1- Assigning Primary Key to the suitable field i.e “EmployeeID”
which can be capable of identifying each record uniquely. If it is already assigned by computer
then no need to re-assign it.

13-Save the Table once again to update changes.

Requirement#2-Entering Five(5) Records


14-Now double click “Employee” table to open it. Enter valid data into it. Use mouse to toggle
b/w the fields of each record. Continue adding the record until you complete entering desired
records. After it, close & finish record entry.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 81


XII PRACTICAL C & Access Database 2020-21

Queries Design
15-With the help of mouse click “Create”, then point and left click “Query Design”.

17- “Show table” panel will be open, select ” Table” tab from “Table/Query/Both”.
Point and double left click the desired tables from available list of tables, to add these
tables then left click “cross/close” present on top-right hand side of the panel, to close
it.

18- Select field name from the available list of “combo-box”, which you want to display
or manipulate. Table name of that particular field will automatically be added after your
selection of field. Mention the criteria if you want. Uncheck the ”CheckBox” if you don’t
want to display this field.

19- Do repeat above step number 19 for each and every field, you want more to display
or manipulate until you complete all desired field entries

20- Now in the “criteria” cell of field “EmployeeID” enter the contents “[Enter
EmployeeID?]” to create the query of “Display Particular Record by Employee ID” and
then Left click the “Cross/Close” button to close the Query Panel, left click “Yes” Button
to save the Query1 with the new name “Employees By ID”, again left click “Ok” Button.
You can save query with your desired name as well.

21- Now in the “criteria” cell of field “Address” enter the contents “Like * Gulshan-e-
Iqbal Karachi” to create the query of “Records having same address” and then Left click
the “Cross/Close” button to close the Query Panel, left click “Yes” Button to save the
Query1 with the new name “Employees By Address”, again left click “Ok” Button. You
can save query with your desired name as well.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 82


XII PRACTICAL C & Access Database 2020-21

22- Repeat from above step number 17 to 21 for creating remaining queries, just
remove the contents of criteria cell, as per your requirement.

Obtaining Query Results


22-Double click any query to display its result, if there is a need of passing any value
then just type-in the value you want to pass into the panel that appears before you.

Output
Requirement#3. Display particular record by EmployeeId

Requirement#4- Display All records having the same Address

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 83


XII PRACTICAL C & Access Database 2020-21

Practical No.7

Object Write a procedure to create a two tables having the


following fields

Table1:AccountNo, AccountName, HolderAddress, Contact, Email.


Table2:AccountNo, AccountStatus.

Queries
1. Input 5 records
2. Search the desired AccountNo
3. Delete the desired AccountNo
4. Update desired AccountId.

Procedure

Switching on Computer
1- Switch on your computer. Wait till the operation system “Windows” let you give access to
interact with the computer.

Searching and Opening MS-Access


2-With the help of mouse click “Start” Icon, generally present at bottom left side of the
computer screen‫۔‬

3-Use Mouse click “Search Bar”, type “Microsoft Office Access” in it with the help of computer
keyboard to search and open MS-Access.

Creating Database
4-Point Mouse Cursor to Blank Database, it will be highlighted then click it with mouse.

5- New panel at right hand side will be open, point your mouse cursor to the file name location,
type new name “BankAccountDatabase” there then click “Create” button.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 84


XII PRACTICAL C & Access Database 2020-21

Creating & Renaming Tables


6-Another big new panel at right hand side will be open, point your mouse cursor to “Table1:
Table” icon, it will be highlighted then right click it, with the mouse. A “drop-down menu” will
be open, click second option “Design View” from it.
7- Now “Save As” panel will be open, give new name “BankAccount” in the text box to Save
“Table1” as “BankAccount”, then press “ok” Button.

8-Type in the “Field Name” text value “AccountNo”.

9- Use mouse to point the cell below “Data Type”, select there “Auto Number” from the
available “combo box” option list.
10- Use mouse to point the next cell present under “Description” heading, type the description
whatever you want to write for your future reference or let it remain empty.

11- Repeat above steps till all the remaining fields (AccountName, HolderAddress, Contact,
Email) with “data types” and “description” are properly typed into the corresponding cell of
Database Design Window. Always use “Text” data type for fields like [Name, Address, Contact,
Email etc.], “AutoNumber” for automatic assignment of numbers. “Numeric” for fields on
which calculation are performed, “Currency” for fields like [wages, salary], “Date” for fields
which are supposed to store dates, “Hyperlink” for fields holding [websites / urls etc.], “OLE
Object” for picture, photographs, “Yes/No” for status showing field, “Attachment” for external
files, “Memo” for descriptive fields.”Lookup Wizard” for foreign fields from other tables of the
database.
12- Repeat steps 6 to 11 for “AccountStatus” Table having fields (AccountNo as Foreign Key
from BankAccount Table, AccountStatus)

13-
Assigning Primary Key to the suitable field i.e “AccountNo” in “BankAccount” table as
well as in “Account Status” table which can be capable of identifying each record uniquely.

14-Save the Tables once again to update changes.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 85


XII PRACTICAL C & Access Database 2020-21

Requirement#1- Entering Five(5) Records


15-Now double click “BankAccount” and “Account Status” tables repectively, to open it. Enter
valid data into it. Use mouse to toggle b/w the fields of each record. Continue adding the record
until you complete entering desired records. After it, close & finish record entry.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 86


XII PRACTICAL C & Access Database 2020-21

Queries Design
16-With the help of mouse click “Create”, then point and left click “Query Design”.

17- “Show table” panel will be open, select ” Table” tab from “Table/Query/Both”.
Point and double left click the desired tables from available list of tables, to add these
tables then left click “cross/close” present on top-right hand side of the panel, to close
it.

18- Select field name from the available list of “combo-box”, which you want to display
or manipulate. Table name of that particular field will automatically be added after your
selection of field. Mention the criteria if you want. Uncheck the ”CheckBox” if you don’t
want to display this field.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 87


XII PRACTICAL C & Access Database 2020-21
19- Do repeat above step number 19 for each and every field, you want more to display
or manipulate until you complete all desired field entries

20- Now in the “criteria” cell of field “AccountNo”, table “BankAccount” enter the
contents “[BankAccount].[givenAccount]” to create the query of “all records having
same department” and then Left click the “Cross/Close” button to close the Query
Panel, left click “Yes” Button to save the Query1 with the new name “BankRecord
Display By Id”, again left click “Ok” Button. You can save query with your desired name
as well.

21- Repeat from above step number 17 to 21 for creating remaining queries, just
remove the contents of criteria cell, as per your requirement.

Obtaining Query Results


22-Double click any query to display its result, if there is a need of passing any value
then just type-in the value you want to pass into the panel that appears before you.

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 88


XII PRACTICAL C & Access Database 2020-21

Output
Requirement#2-Search Account by ID

Requirement#3- Delete Account by ID

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 89


XII PRACTICAL C & Access Database 2020-21

Requirement#4- Update Account by ID

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 90


XII PRACTICAL C & Access Database 2020-21

Mohsin Ahmed Khan Ghori (Lecturer) | [Link] Page 91

You might also like