Computer Practical

Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

Academic Year 202

2021-2022
Certificate

This is to certify that Mr.____________________


M ____________________ of class X
XII

Computer Science group has carried out necessary practical work

for the course Computer Science – III as prescribed by the Board of

Intermediate Education Karachi for the academic year _________.

Date:____________

Course Incharge _______________

____________________
Head of the Department
List of Practicals of C-language
1) Write a program in c-language to calculate the Roots of a Quadratic Equation given the three coefficients a,b,c
2) Write a program in c-language to calculate the Area of a Triangle and Volume of a Sphere
3) Write a program in c-language to print whether an inputted integer is Even or Odd
4) Write a program in c-language to print whether an inputted integer is Positive or Negative
5) Write a program in c-language to input the year and print whether it is a leap year or not
6) Write a program in c-language to input an alphabet and print whether it is a vowel or not
7) Write a program in c-language to create a marksheet which prints percentage and grade after inputting marks
of 5 subjects

8) Write a program in c-language to draw a Check-board using loops and conditionals


9) Write a program in c-language which reads three different integers and prints the largest amongst them
10) Write a program in c-language which shows efficient use of switch and break statements
11) Write a program in c-language to Swap the values of two integers without using third helping variable
12) Write a program in c-language to print the list of ASCII codes from 0 to 255
13) Write a program in c-language to generate the table of an inputted integer
14) Write a program in c-language to print the Factorial of an inputted integer
15) Write a program in c-language to print Prime numbers upto a given number
16) Write a program in c-language that uses do-while loop to print Even numbered series upto N (where N is any
inputted integer)
17) Write a program in c-language that uses do-while loop to print Odd numbered series upto N (where N is any
inputted integer)
18) Write a program in c-language to print the cube of an inputted integer, using function
19) Write a program in c-language to convert the case of an inputted character from lower to upper and upper to
lower , using function
20) Write a program in c-language to add two inputted integers, using function
21) Write a program in c-language to search for a given integer from a 10-element integer array
22) Write a program in c-language to sort a 10-element integer array
23) Write a program in c-language to check whether the two inputted strings are palindrome or not
24) Write a program in c-language which uses nested loop to print the following pattern
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
25) Write a program in c-language which uses nested loop to print the following pattern
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
26) Write a program in c-language
language to print whether an inputted integer is Prime number or not
27) Write a program in c-language
language to input temperature
temperature of 7 days of week and print Average temperature
28) Write a program in c-language
language for inputting and displaying Two Matrices
29) Write a program in c-language
language to input Two Matrices and then display the Sum and Difference of the Two
Matrices
30) Write a program in c-language
language to find out the greatest among three inputted integers
31) Write a program in c-language
language to find out the greatest among three inputted integers, using UDF
32) Write a program that reads Base and Exponent & gives the answer as BaseExponent ( without using pow function)
33) Write a program that displays the factorial of any inputted positive integer, using UDF
34) Write a program using nested for loop to display the following patern

35) Write a program to input two values and then print their LCM and GCD
Practical
1

Object:
Write a program in c language to calculate the roots of quadratic equation given the
three coefficients a, b, c.

Source code:
#include<stdio.h>

#include<conio.h>

#include<math.h>

void main(void)

int a,b,c,d;

float x1,x2;

clrscr();

printf("\nEnter three integers: ");

scanf("%d%d%d",&a,&b,&c);

d=pow(b,2)-(4*a*c);

if(d<0)

printf("\nTHE ROOTS ARE IMAGINARY");

else

x1=(-b+sqrt(d))/(2*a);

printf("\t%.2f",x1);
x2=(-b-sqrt(d))/(2*a);

printf("\t%.2f",x2);

getch();
}

Practical no.2

Object:

Write a program which use arithmetic operators to calculate the Area of triangle and
Volume of sphere.

Source Code:
#include<stdio.h>

#include<conio.h>

#include<math.h>

void main (void)

float a,b,r,t,s;

printf(“Enter altitude of triangle :”);

scanf(“%f”,&a);

printf(“\nEnter base of triangle:”);

scanf(“%f”,&b);

printf(“\nEnter radius of triangle:”);

scanf(“%f”,&r);

t= (1.0/2.0)*a*b;
s= (4.0/3.0)*(22/7)*pow(r,3);

printf(“\n Area of triangle =%.2f”,t);

printf(“\n Volume of sphere =%.2f”,s);

getch();

}
Practical no.03

Object:
Write a program in c-language to print whether an inputted integer is even or odd.

Source code:
#include<stdio.h>

#include<conio.h>

void main(void)

int n;

clrscr();

printf("\nEnter a number: " );

scanf("%d",&n);

if(n%2==0)

printf("%d is even",n);

else

printf("%d is odd",n);

getch();

Practical no.4

Object:
Write a program in c-language to print whether an inputted integer is positive or
negative.

Source code:
#include<stdio.h>

#include<conio.h>

void main(void)

int n;

clrscr();

printf("\nEnter a number: ");

scanf("%d",&n);

if(n>0)

printf("\nPOSITIVE NUMBER");

else if(n<0)

printf("\nNEGATIVE NUMBER");

getch();

Practical no.5

Object:
Write a program in c-language to input the year and print whether it is a leap year or not.

Source Code:
#include<stdio.h>

#include<conio.h>

void main(void)

int year;

clrscr();

printf("\nEnter The Year:");

scanf("%d",&year);

if(year%4==0)

printf("\nThis is a leap year");

else

printf("\nThis is not a leap year");

getch();

Practical no .06

Object:
write a program in C language to input an alphabet and print whether it is vowel or not.

Source code:
#include<stdio.h>

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

char ch=getche();

clrscr();

switch(ch)

case ‘i’:

case ‘o’:

case ‘a’:

case ‘e’:

case ‘u’:

case ‘A’:

case ‘E’:

case ‘I’:

case ‘O’:

case ‘U’:

printf("\nThis is vowels");

break;

default:

printf("\nThis is consonents");

getch();

}
Practical no.7

Object:
Write a program in c-language to create a marksheet which prints percentage and grade
after inputting marks of 5 subjects.

Source Code:
#include<stdio.h>

#include<conio.h>

void main(void)

inta,b,c,d,e,total;

float per;

clrscr();

printf("\nEnter the marks for 5 subjects: ");

scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);

total=a+b+c+d+e;

per=(total/500.0)*100;

printf("\nThe percentage is %.2f",per);

if(per>=90||per>=80)

printf("\nThe grade is A+");

else if(per>=70&&per<=79)
printf("\nThe grade is A");

else if(per>=60&&per<=69)

printf("\nThe grade is B");

else if(per>=50&&per<=59)

printf("\nThe grade is C");

else if(per>=40&&per<=49)

printf("\nThe grade is D");

else

printf("\nFail");

getch();

Practical no. 8

Object:
Write a program in C language to draw a check-board using loops and conditionals.

Source Code:
#include<stdio.h>

#include<conio.h>

void main(void)

inti,j;

clrscr();

for(i=1;i<=8;i++)
{

for(j=1;j<=8;j++)

if((i+j)%2==0)

printf("\xDB\xDB");

else

printf(" ");

printf("\n");

getch();

Practical no. 9

Object:
Write a program in c-language which reads three different integers and prints the
largest amongst them.

Source Code:

#include<stdio.h>

#include<conio.h>

void main(void)
{

int a,b,c;

clrscr();

printf(“\nenter three integers: “);

scanf(“%d%d%d”,&a,&b,&c);

if(a>b&& a>c)

printf(“\n %d is largest”,a);

else if(b>a&&b>c)

printf(“\n%d is largest”,b);

else

printf(“\n%d is largest”,c);

getch();

Practical no.10

Object:
Write a program in c-language which shows efficient use of switch and break
statement.

Source code:
#include<stdio.h>

#include<conio.h>

void main(void)
{

clrscr();

inta,b;

charch;

printf("enter first number");

scanf("%d",&a);

printf("enter second number");

scanf("%d",&b);

ch=getche();

switch(ch)

case '+':

printf("addition is %d",a+b);

break;

case '-':

printf("subtraction is %d",a-b);

break;

case '*':

printf("multiply is %d",a*b);

break;

case '/':

if(b!=0)

printf("division is %d",a/b);
break;

default:

printf("operation error\n");

getch();

Practical no.11

Object:
Write a program in c-language to swap the value of two integer without using third
helping variable.

Source code:
#include<stdio.h>

#include<conio.h>

void main(void)

int a,b;

clrscr();

printf("\nEnter two numbers: ");

scanf("%d%d",&a,&b);

a=a+b;

b=a-b;

a=a-b;
printf("\na=%d and b=%d",a,b);

getch();

Practical no.12
Object:
Write a program in c-language to print the list of ASCII codes from 0 to 255.

Source Code:

#include<stdio.h>
#include<conio.h>
#include<dos.h>
void main(void)
{
int i;
clrscr();
for(i=0;i<=255;i++)
{
printf("\n %d\t%c",i,i);
delay(500);
}
getch();
}

Practical No:13

Object:
Write a program in c language to generate the table of an inputted integers.

Source code:
#include<stdio.h>

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

inti,a;

clrscr();

printf("\nEnter a table no : ");

scanf("%d",&a);

for(i=1;i<=10;i++)

printf("\n%d * %d = %d",a,i,a*i);

getch();

Practical no. 14

Object:
Write a program in c language to print the factorial of an inputted integer

Source Code:
#include<stdio.h>

#include<conio.h>

void main(void)
{

int a,i;

double f=1;

clrscr();

printf(“\n Enter a number whose factorial is find: “);

scanf(“%d”,&a);

for(i=1;i<=a;i++)

f=f*i;

printf(“\n the factorial number %d is %.2lf”,a,f);

getch();

Practical No:15

Object:
Write a program in c language to print prime numbers upto a given number.

Source code:

#include<stdio.h>

#include<conio.h>

void main(void)

int n=0,x,i,j;
clrscr();

printf("\nEnter a number: ");

scanf("%d",&x);

for(i=2;i<=x;i++)

for(j=1;j<=i;j++)

if(i%j==0)

n++;

if(n==2)

printf("%d\t",i);

n=0;

getch();

}
Practical no.16

Object:
Write a program in c-languagethat use do-while loop to print even numbered series
uptoN(where N is any inputted series).
Source code:
#include<stdio.h>

#include<conio.h>

void main(void)

intn,i=0;

clrscr();

printf("\nEnter integer number: ");

scanf("%d",&n);

do

printf("\n%d",i);

i=i+2;

while(i<=n);

getch();

Practical no.17

Object :
Write a program in c-language that uses do-while loop to print Odd numbered series
upto N(where N is any inputted integer).

Source Code :
#include<stdio. h>
#include<conio. h>

void main (void)

int number;

int n;

number=1;

printf("Enter the value of N: ");

scanf("%d",&n);

Do

printf("Odd Numbers “) ;

While

(number<=n)

if(number%2 != 0)

printf("\n%d ",number);

number++;

getch() ;

Practical no.18

Object:
Write a program in c-language to print the cube of an inputted integer using function.
Source Code:
#include<studio.h>

#include<conio.h>

int cube (int x)

return(x*x*x);

void main (void)

int n, k;

clrscr();

printf (“Enter any integer =”);

scant(“%d” , &n);

k = cube (n);

printf(“/n Cube of %d”, n, k);

getch();

Practical no.19

Object:
Write a program in c-language to convert the case of an inputted character from lower
to upper and upper to lower , using function.

Source Code:
#include<stdio.h>

#include<conio.h>

Void changecase(char x)

if(x>=65&&x<=90)

x=x+32;

printf(“ \n The small alphabet is %c”,x);

else if(x>=97&&x<=122)

x=x-32;

printf(“ \n The capital alphabet is %c”,x);

else

printf(“ \n Invalid alphabet “);

void main(void)

{
char a;

clrscr();

printf(“ \n Enter any alphabet : “);

a=getche();

changecase (a);

getch();

Practical no.20

Object:
Write a program In C-language to add two inputted integers, using function.

Source code:

#include<stdio.h>
#include<conio.h>
int add(int,int);
void main(void)
{
inta,b,c;
clrscr();
printf("\nEnter two numbers : ");
scanf("%d%d",&a,&b);
c=add(a,b);
printf("\nThe addition is %d",c);
getch();
}
int add(intx,int y)
{
int z;
z=x+y;
return(z);
}

Practical no. 21

Object:
Write a program in c-language to search for a given integer from a 10-element integer
array.

Source Code:
#include<stdio.h>

#include<conio.h>

void main(void)

int arr[10],i,search;

clrscr();

for(i=0;i<=9;i++)

printf("\nEnter array element at index no %d : ",i);

scanf("%d",&arr[i]);

}
printf("\nEnter a number whose find it: ");

scanf("%d",&search);

for(i=0;i<=9;i++)

if(search==arr[i])

printf("\n%d Is present at location %d",search,i);

break;

if(i>9)

printf("\nNOT FINDED");

getch();

Practical no.22

Object:
Write a program in c-language to sort a 10 element integer array.

Source Code:
#include<stdio.h>

#include<conio.h>

void main(void)
{

int arr[10],i,j,temp;

clrscr();

for(i=0;i<=9;i++)

printf("\nEnter array elements at index %d : ",i);

scanf("%d",&arr[i]);

for(i=0;i<=9;i++)

for(j=i;j<=9;j++)

if(arr[i]>arr[j])

temp=arr[i];

arr[i]=arr[j];

arr[j]=temp;

printf("\nElements of array in sorted: ");

for(i=0;i<=9;i++)

{
printf("\n%d",arr[i]);

getch();

}
Practical no.23
Object:
Write a program in c-language to check wheather the one
string are palindrome or not.

Source code:

#include<stdio.h>
#include<conio.h> `
#include<string.h>
void main(void)
{
charstr[10],str2[10];
clrscr();
printf("\nEnter a string: ");
gets(str);
gets(str2);
strrev(str);
strrev(str2);
puts(str);
puts(str2);
if(strcmp(str,str2)==0)
printf("\nThe strings are palindrome");
else
printf("\nIts not palindrome");
getch();
}
Practical no.24

Object:
Write a program in c-language which uses nested loop to print the following pattern
Source Code:
#include<stdio.h>

#include<conio.h>

void main(void)

int i,j;

clrscr();

for(i=5;i>=1;i--)

for(j=1;j<=i;j++)

printf("%d",j);

printf("\n");

getch();

Practical no:25

Object:

Write a program in c language which uses nested loop to print the following pattern.

Source code:
#include<stdio.h>

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

inti,j;

for(i=1;i<=5;i++)

for(j=1;j<=i;j++)

printf("%d",j);

printf("\n");

getch();

Practical no.26

Object :
Write program to determine whether the inputted number is prime or not.

Source Code:
#include<stdio.h>

#include<conio.h>

void main(void)

int n,i,flag=0;

clrscr();

printf("\nEnter a number: ");


scanf("%d",&n);

for(i=2;i<n;i++)

if(n%i==0)

printf("\nNOT PRIME NUMBER");

flag=1;

break;

if(flag==0)

printf("\nTHIS NUMBER IS PRIME");

getch();

Practical no:27

Object:
Write a program in c language to input temperature of 7 days of week and print the
average temperature.

Source code:
#include<stdio.h>

#include<conio.h>
Void main(void)

Float m,t,w,th,f,st,s,average;

Clrscr();

Printf(“\nEnter the temperature of & days of week:”);

Scanf(“%f%f%f%f%f%f%f”,&m,&t,&w,&th,&f,&st,&s);

average=(m+t+w+th+f+st+s)/7;

printf(“\n The average temperature is %.2f”,average);

getch();

Practical no .28

Object:
Write a program in c-language for inputting and displaying two matrices

Source code:
#include<stdio.h>

#include<conio.h>

void main(void)

int a[3][3],b[3][3],i,j,c,d;

clrscr();

printf("\nEnter first matrix: \n");

for(i=0;i<3;i++)
{

for(j=0;j<3;j++)

scanf("%d",&a[i][j]);

printf("\n");

printf("\nEnter second matrix: \n");

for(i=0;i<3;i++)

for(j=0;j<3;j++)

scanf("%d",&b[i][j]);

printf("\n");

for(i=0;i<3;i++)

for(j=0;j<3;j++)

printf("\t%d",a[i][j]);

printf("\n");

printf("\n");

for(i=0;i<3;i++)

{
for(j=0;j<3;j++)

printf("\t%d",b[i][j]);

printf("\n");

getch();

Practical no.29
Object:
Write a program to input two matrix and find sum and difference of two
matrix.

Source code:

#include<stdio.h>
#include<conio.h>
void main (void)
{
intarr[3][3];
intbrr[3][3];
intsum,diff,i,j;
printf("enter the value of 1st matrix");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf("%d",&arr[i][j]);
}
printf("enter the value of 2nd matrix");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf("%d",&brr[i][j]);
}
clrscr();
printf("sum of two matrix\n");
for(i=0;i<3;i++)
{
for( j=0;j<3;j++)
{
sum=arr[i][j]+brr[i][j];
printf("%3d",sum);
}
printf("\n");
}
printf("\ndiffernece of two matrix\n");
for(i=0;i<3;i++)
{
for( j=0;j<3;j++)
{
diff=arr[i][j]-brr[i][j];
printf("%3d",diff);
}
printf("\n");
}

getch();
}

Practical no 30

Object:

write a program to input 3 integers and find out the


greatest

Source code:

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

void main (void)


{
int a,b,c;
printf("enter three numbers");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
printf("%d is greatest",b);
else
printf("%d is greatest",c);
getch();
}

Practical no. 31

Object:
Write a program to find the maximum of three integer number
using user defined function.

Source Code:

#include<stdio.h>
#include<conio.h>
int max(int,int,int);
void main(void)
{
int a,b,c,d;
printf("enter three numbers");
scanf("%d%d%d",&a,&b,&c);
d=max(a,b,c);
printf("%d is greatest ",d);
getch();
}
int max(int x,int y, int z)
{
int u;
if(x>y &&y>z)
u=x;
else if (y>x && y>z)
u=y;
else
u=z;
return(u);
}

Practical no:32
Object:
Write a program to read base and exponent and give answer of
base.

Source code:

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main (void)
{
intbase,exp,ans;
clrscr();
printf("\nEnter a base and exponent: ");
scanf("%d%d",&base,&exp);
ans=pow(base,exp);
printf("\nThe answer is %d",ans);
getch();
}
Practical no.33

Object:
Write a program that displays the factorial of any inputted positive integer using UDF.

Source code:
#include<stdio.h>
#include<conio.h>
double fact(int);

void main(void)

{
int a;

double f;

clrscr();

printf(“\nenter a number: “);

scanf(“%d”,&a);

f=fact(a);

printf(“\nits factorial is %.2lf”,f);

getch();

double fact(int x)

double f1=1;

inti;

for(i=1;i<=x;i++)

f1=f1*i;

return(f1);

}
Practical no.34

Object:
Write a program using nested for loop to display the following pattern.

Source code:
#include <stdio.h>

#include<conio.h>

void main(void)

inti, space, rows, k = 0;

printf("Enter the number of rows: ");

scanf("%d", &rows);

for (i = 1; i<= rows; ++i, k = 0)

for (space = 1; space <= rows - i; ++space)

printf(" ");

while (k != 2 * i - 1)

printf("* ");

++k;

}
printf("\n");

getch();

Practical no.35

Object:
Write a program to input two values and then print LCM and GCD.

Source code:
#include<stdio.h>

#include<conio.h>

void main(void)

int a,b,x,y,gcd,lcm;

clrscr();

printf("\nEnter Two Values: ");

scanf("%d%d",&a,&b);

x=a;

y=b;

while(a!=b)

if(a>b)
a=a-b;

else

b=b-a;

gcd=b;

printf("\nThe GCD is %d",gcd);

lcm=(x*y)/gcd;

printf("\nThe LCM is %d",lcm);

getch();

}
INDEX
(Database)
No Date Practical Page Initial Remarks
1.
Create a Database of Student information (Stud_Id, Name, Class,
Group, Sex)
(i) Create Stud_Id as primary key.
(ii) Input 20 records.
(iii) Find the list of Female Pre-Engineering group
(iv) Find the list of Male Pre-Engineering group

2.
Create a Database of Students result information (Stud_Id, Name,
St_marks)
(i) Create primary key as st_id
(ii) input 10 records
(iii) Sort all records on descending Order on st_marks
(iv) Display all records

3.
Create a Database of Library (Book_Id, Name, status)
(i) Create a suitable primary key, input 20 records
with different names.
(ii) Display a list of Books which are issued
(iii) Find the list of available Books
.
4.
Create a Database in MS-Access of Student Attendance. Create
two Tables, create Relationship between Tables.
(i) Required fields of first table are;
Stud_Id, St_Name, St_Address, St_Phone,
St_Email.
(ii) Required field of second table are;
Stud_Id, St_Attendance.
(iii) Search the desired Stud_Id, delete the desired
Stud_Id also update the desired Stud_Id.

5.
Create a Database in Ms Access of Bank Accounts.
Create two Tables, create Relationship between Tables.
(i) Required fields of first table are:
Acct_Id, Acct_Name, Acct_ Address,
Acct_Phone, Acct_Email.

(ii) Required fields second table are:


Acct_Id, Acct_Status.
(iii) Search the desired Acct_Id, delete the desired
Acct_Id also update desired Acct_Id.
6.
Create a Hospital record Database in MS Access.
(i) Create two Tables, input five records.
(ii) Create Patient_Id as primary key.
(iii) Create Relationship between Tables.
(iv) Search all Patients under treatment of a
particular Doctor Name “Muhammad faizan”.
(v) Update the Prescription of a particular Patient.

Patient
Patient_id Name Address Doctor Admit Discharge Discharge charges
Name date status date

Status
Patient_id Date Doctor Test Report Prescription Disease
Name

7. Write a procedure or steps to create a table TEACHER having the


following fields:
FACULTY_ID, TEACHER_NAME, DESIGNATION,
DEPARTMENT.
Queries.
1. Assign primary key to a suitable column.
2. Input 5 records
3. Display all records having same DEPARTMENT.
4. List all the records with designation LECTURER
8. Write a procedure or steps to create a table EMPLOYEES having
the following fields:
EMP_ID, EMP_NAME, ADDRESS, POSTCODE, DATE_HIRED,
WAGES
Queries.
1. Assign primary key to a suitable column.
2. Input 5 records
3. Display a particular record by EMP_ID
4. Display those records who have the same ADDRESS

9. Write a procedure or steps to create a table STUDENT having the


following fields:
STD_ID, ST_NAME, CLASS, GROUP, GENDER
Queries.
1. Create STD_ID as Primary Key
2. Input 5 records
3. Find the list of female students
4. Find the list of male students

10. Write a procedure or steps to create a table STUDENT having the


following fields:
STUDENT_ID, STUDENT_NAME, ADDRESS, CELLNO
Queries.
1. Assign primary key to a suitable column.
2. Input 5 records
3. Display all records
4. Search only one record by STUDENT_ID
MS- Access Object Practical No. 01
Create a Database of Student information (Stud_Id, Name, Class, Group, Sex)
(i) Create Stud_Id as primary key.
(ii) Input 20 records.
(iii) Find the list of Female Pre-Engineering group
(iv) Find the list of Male Pre-Engineering group
Procedure
1. Create a Database of Student
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Student in the file name text box
❖ Select location of the database and click Create button
2. Create Student table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Stud_Id and select Number from Data Type menu
❖ Right click Field Selector button and select Primary Key from menu.
❖ Add four more fields Stud_Name , class , group and sex with data type Short Text of all
fields.
❖ Press Ctrl+s to save the table with Student name
3. Input 20 Records with different names
❖ Open the table object Student by double clicking in Navigation Pane and insert records
of 20 students of your choice according to data types.
4. Find the list of Female Pre-Engineering group
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Student and click Add and
Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Stud_id in first field, Stud_name in second field, class in third field, group in
fourth field and sex in fifth field.
❖ Type ‘female’ in Criteria of sex field and type ‘pre-engineering’ in Criteria of group field,
so that only female students with pre-engineering group will appear.
❖ Press Ctrl+s to save the query with query name query_female_pe.
❖ To run the query double-click query object query_female_pe in Navigation Pane.
5. Find the list of Male Pre-Engineering group
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Student and click add and
Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Stud_id in first field, Stud_name in second field, class in third field, group in
fourth field and sex in fifth field.
❖ Type ‘male’ in Criteria of sex field and type ‘pre-engineering’ in Criteria of group field, so
that only male students with pre-engineering group will appear.
❖ Press Ctrl+s to save the query with query name query_male_pe.
❖ To run the query double-click query object query_male_pe in Navigation Pane.
MS- Access Object Practical No. 02
Create a Database of Students result information (Stud_Id, Name, St_marks)
i. Create primary key as st_id
ii. input 10 records
iii. Sort all records on descending Order on st_marks
iv. Display all records
Procedure
1. Create a Database of Student
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Student in the file name text box
❖ Select location of the database and click Create button
2. Create Student table.
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type St_Id and select Number from Data Type menu
❖ Right click Field Selector button and select Primary Key from menu.
❖ Add two more fields St_Name and St_marks with data types Short Text and Number
respectively.
❖ Press Ctrl+s to save the table with Student name
3. Input 10 Records of students with different names
❖ Open the table object Student by double clicking in Navigation Pane and insert records
of 10 Students of your choice according to data types.
4. Sort all records on descending order on student marks.
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Student and click add and
Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select St_id in first field, St_name in second field and St_marks in the third field.
❖ Select Descending from sort menu of st_marks field, so that students will appear in
descending order according to marks.
❖ Press Ctrl+s to save the query with query name query_std_marks.
❖ To run the query double click query object query_std_marks in Navigation Pane.
5. Display all records.
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Student and click add and
Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select St_id in first field, St_name in second field and St_marks in the third field.
❖ Press Ctrl+s to save the query with query name query_student.
❖ To run the query double-click query object query_student in Navigation Pane.
MS- Access Object Practical No. 03
Create a Database of Library (Book_Id, Name, status)
(i) Create a suitable primary key, input 20 records with different names.
(ii) Display a list of Books which are issued
(iii) Find the list of available Books

Procedure
1. Create a Database of Library
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Library in the file name text box
❖ Select location of the database and click Create button
2. Create table Book
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Book_Id and select Number from Data Type menu
❖ Right click Field Selector button and select Primary Key from menu.
❖ Add two more fields Book_Name and Status with data type Short Text of both fields.
❖ Press Ctrl+s to save the table with books name
3. Input 20 Records with different names
❖ Open the table object books by double clicking in Navigation Pane and insert records of
20 books of your choice according to data types.
4. Display a list of Books which are issued
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table books and click add and
Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Book_id in first field, Book_name in second field and status in the third field.
❖ Type ‘issued’ in Criteria of status field, so that only issued books will appear.
❖ Press Ctrl+s to save the query with query name query_issued.
❖ To run the query double click query object query_issued in Navigation Pane.
5. Find the list of available Books
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table books and click add and
Close to close the Show Table dialog box.
❖ The Query Design screen will appear
❖ Select Book_id in first field, Book_name in second field and status in the third field.
❖ Type ‘Available’ in Criteria of status field, so that only available books will appear.
❖ Press Ctrl+s to save the query with query name query_available.
❖ To run the query double click query object query_available in Navigation Pane.
MS- Access Object Practical No. 04
Create a Database in MS-Access of Student Attendance. Create two Tables, create Relationship between Tables.
(i) Required fields of first table are;
Stud_Id, St_Name, St_Address, St_Phone, St_Email.
(ii) Required field of second table are;
Stud_Id, St_Attendance.
(iii) Search the desired Stud_Id, delete the desired Stud_Id also update the desired Stud_Id.

Procedure
1. Create a Database of Student
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Student in the file name text box
❖ Select location of the database and click Create button
2. Create Student table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type St_Id and select Number from Data Type menu
❖ Right click Field Selector button and click Primary Key from menu.
❖ Add four more fields St_Name, St_Address, St_Phone and St_Email with data types
Short Text , Long Text, Short Text and Hyperlink, respectively
❖ Press Ctrl+s to save the table with Student name
3. Create Attendance table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type St_Id and select Number from Data Type menu
❖ Right click Field Selector button and click Primary Key from menu.
❖ Add one more field St_Attendance with Number data type
❖ Press Ctrl+s to save the table with Attendance name
4. Create Relationship between two tables.
❖ Click Database Tools tab.
❖ Click Relationships
❖ The Show Table dialog box will appear and select both tables by holding ctrl key
then click add and Close to close the Show Table dialog box.
❖ Drag the field St_id from one table to the common field (foreign key) in the other
table
❖ Edit Relationship dialog box will appear, and press Create button.
5. Search the desired St_Id
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table student and click add
and Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select st_id in first field, st_name in second field, st_address in t third field, st_phone
in fourth field and st_email in fifth field.
❖ Type 15 in Criteria of st_id field, to search that id.
❖ Press Ctrl+s to save the query with query name query_search.
❖ To run the query double click query object query_search in Navigation Pane.
6. Delete the desired St_Id
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table student and click add
and Close to close the Show Table dialog box.
❖ Select Delete from Query Type group
❖ The Query Design screen will appear
❖ Select st_id in first field
❖ Type 10 in Criteria of st_id field, to delete that id.
❖ Press Ctrl+s to save the query with query name query_delete.
❖ To run the query double click query object query_delete in Navigation Pane.
7. Update the desired St_Id
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table student and click add
and Close to close the Show Table dialog box.
❖ Select Update from Query Type group
❖ The Query Design screen will appear
❖ Select st_id in first field
❖ Type 25 in Update To and 15 in Criteria of st_id field, to update that st_id from 15
to 25.
❖ Press Ctrl+s to save the query with query name query_update.
❖ To run the query double click query object query_update in Navigation Pane.
MS- Access Object Practical No. 05
Create a Database in Ms Access of Bank Accounts. Create two Tables, create Relationship between Tables.
(i) Required fields of first table are:
Acct_Id, Acct_Name, Acct_ Address, Acct_Phone, Acct_Email.
(ii) Required fields second table are:
Acct_Id, Acct_Status.
(iii) Search the desired Acct_Id, delete the desired Acct_Id also update desired Acct_Id.

Procedure
1. Create a Database of Bank
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Bank in the file name text box
❖ Select location of the database and click Create button
2. Create Account table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Acct_Id and select Number from Data Type menu
❖ Right click Field Selector button and click Primary Key from menu.
❖ Add four more fields Acct_Name, Acct_Address, Acct_Phone and Acct_Email with data
types Short Text , Long Text, Short Text and Hyperlink, respectively
❖ Press Ctrl+s to save the table with Bank name
3. Create Status table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Acct_Id and select Number from Data Type menu
❖ Right click Field Selector button and click Primary Key from menu.
❖ Add one more field St_Status with Short Text data type
❖ Press Ctrl+s to save the table with Status name
4. Create Relationship between two tables.
❖ Click Database Tools tab.
❖ Click Relationships
❖ The Show Table dialog box will appear and select both tables by holding ctrl key
then click add and Close to close the Show Table dialog box.
❖ Drag the field Acct_id from one table to the common field (foreign key) in the other
table
❖ Edit Relationship dialog box will appear, and press Create button.
5. Search the desired Acct_id
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Account and click add
and Close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Acct_id in first field, Acct_name in second field, Acct_address in the third
field, Acct_phone in the fourth field and Acct_email in fifth field.
❖ Type 100 in Criteria of Acct_id field, to search that id.
❖ Press Ctrl+s to save the query with query name query_search.
❖ To run the query double click query object query_search in Navigation Pane.
6. Delete the desired Acct_id
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Account and click add
and Close the Show Table dialog box.
❖ Select Delete from Query Type group
❖ The Query Design screen will appear
❖ Select Acct_id in first field
❖ Type 100 in Criteria of Acct_id field, to delete that id.
❖ Press Ctrl+s to save the query with query name query_delete.
❖ To run the query double click query object query_delete in Navigation Pane.
7. Update the desired Acct_id
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Account and click add
and Close the Show Table dialog box.
❖ Select Update from Query Type group
❖ The Query Design screen will appear
❖ Select st_id in first field
❖ Type 250 in Update To and 150 in Criteria of Acct_id field, to update that acct_id
from 150 to 250.
❖ Press Ctrl+s to save the query with query name query_update.
❖ To run the query double click query object query_update in Navigation Pane.
MS- Access Object Practical No. 06
Create a Hospital record Database in MS Access.
I. Create following Tables, input five records.
II. Create Patient_Id as primary key.
III. Create Relationship between Tables.
IV. Search all Patients under treatment of a particular Doctor Name “Dr. Muhammad faizan”.
V. Update the Prescription of a particular Patient.

Patient
Patient_id Name Address Doctor Admit Discharge Discharge charges
Name date status date

Status
Patient_id Date Doctor Test Report Prescription Disease
Name

Procedure
1. Create a Database of Hospital
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Hospital in the file name text box
❖ Select location of the database and click Create button
2. Create Patient table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Patient_Id and select Number from Data Type menu
❖ Right click Field Selector button and click Primary Key from menu.
❖ Add seven more fields Patient_Name data type Short Text, Address data type Long Text,
Doctor_name data type Short Text, Admit_date data type Date/Time and select Short
Date from Field Properties→General→Format, Discharge_status data type Short Text,
Discharge_date data type Date/Time and select Short Date from Field
Properties→General→Format, charges data type Currency.
❖ Press Ctrl+s to save the table with Patient name
3. Create Status table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Patient_Id and select Number from Data Type menu
❖ Right click Field Selector button and click Primary Key from menu.
❖ Add Five more fields Date data type Date/Time and select Short Date from Field
Properties→General→Format, Doctor_name data type Short Text, Test_Report
data type Long Text, Prescription data type Long Text, Disease data type Long Text.
❖ Press Ctrl+s to save the table with Status name
4. Create Relationship between two tables.
❖ Click Database Tools tab.
❖ Click Relationships
❖ The Show Table dialog box will appear and select both tables by holding ctrl key
then click add and Close to close the Show Table dialog box.
❖ Drag the field Patient_id from one table to the common field (foreign key) in the
other table
❖ Edit Relationship dialog box will appear, and press Create button.

5. Search all Patients under treatment of a particular Doctor Name “Dr. Muhammad faizan”.
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Patient and click add
and Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Patient_id in first field, Patient_name in second field, Doctor_name in the
third field.
❖ Type ‘Dr. Muhammad Faizan’ in Criteria of Doctor_name field, to search all Patients
under treatment of a particular Doctor Name “Dr. Muhammad faizan”.
❖ Press Ctrl+s to save the query with query name query_search.
❖ To run the query double click query object query_search in Navigation Pane.

6. Update the Prescription of a particular Patient.


❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Status and click add and
Close the Show Table dialog box.
❖ Select Update from Query Type group
❖ The Query Design screen will appear
❖ Select Patient_id in first field and select Prescription in second field.
❖ Type 1001 in Criteria of Patient_id field and Type ‘Panadol’ in Update To of
Prescription field, to update Prescription of 1001 patient_id.
❖ Press Ctrl+s to save the query with query name query_update.
❖ To run the query double click query object query_update in Navigation Pane.
MS- Access Object Practical No. 07
Write a procedure or steps to create a table TEACHER having the following fields:
FACULTY_ID, TEACHER_NAME, DESIGNATION, DEPARTMENT.
Queries.
1. Assign primary key to a suitable column.
2. Input 5 records
3. Display all records having same DEPARTMENT.
4. List all the records with designation LECTURER.
Procedure
1. Create a Database of Faculty.
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as faculty in the file name text box
❖ Select location of the database and click Create button
2. Create Teacher table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Faculty_Id and select Number from Data Type menu
❖ Right click Field Selector button and select Primary Key from menu.
❖ Add three more fields Teacher_Name , Designation and Department with data type
Short Text of all fields.
❖ Press Ctrl+s to save the table with Teacher name
3. Input 5 Records with different names
❖ Open the table object Teacher by double clicking in Navigation Pane and insert records
of 5 Teachers of your choice according to data types.
4. Display all records having same DEPARTMENT.
❖ Click Query Wizard in the Queries group on the Create tab.
❖ Select Find Duplicates Query Wizard and press OK button.
❖ Select Table Teacher and press Next.
❖ Select Department from Available Fields Press > and click Next Button to find the
Teachers with same Department.
❖ Press >> and click Next button to show additional fields of Teacher Table.
❖ Type name of query query_same_records in what do you want to name your query?
Text Box and click Finish.
❖ To run the query double-click query object query_same_records in Navigation Pane.
5. List all the records with designation LECTURER
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Teacher and click Add and
Close the Show Table dialog box.
❖ Select Select from query type group
❖ The Query Design screen will appear
❖ Select faculty_id in first field, Teacher_Name in second field, Designation in third field
and Department in fourth field.
❖ Type ‘LECTURER’ in Criteria of Designation field, so that only teachers with Lecturer
Designation will appear.
❖ Press Ctrl+s to save the query with query name query_lecturer.
❖ To run the query double-click query object query_lecturer in Navigation Pane.
MS- Access Object Practical No. 08
Write a procedure or steps to create a table EMPLOYEES having the following fields:
EMP_ID, EMP_NAME, ADDRESS, POSTCODE, DATE_HIRED, WAGES
Queries.
1. Assign primary key to a suitable column.
2. Input 5 records
3. Display a particular record by EMP_ID
4. Display those records who have the same ADDRESS
Procedure
1. Create a Database of Employee.
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Employee in the file name text box
❖ Select location of the database and click Create button
2. Create Employees table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Emp_Id and select Number from Data Type menu
❖ Right click Field Selector button and select Primary Key from menu.
❖ Add five more fields Emp_Name data type Short Text, Address data type Long Text,
Post_code data type Number, Date_Hired data type Date/Time and select Short Date
from Field Properties→General→Format and Wages data type Currency.
❖ Press Ctrl+s to save the table with Employees name
3. Input 5 Records with different names
❖ Open the table object Employees by double clicking in Navigation Pane and insert
records of 5 Employees of your choice according to data types.
4. Display a particular record by EMP_ID
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Employees and click add
and Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Emp_id in first field, Emp_name in second field, Address in t third field,
Post_code in fourth field, Date_Hired in fifth field and Wages in sixth field.
❖ Type 1001 in Criteria of Emp_id field, to search that emp_id.
❖ Press Ctrl+s to save the query with query name query_search.
❖ To run the query double click query object query_search in Navigation Pane
5. Display those records who have the same ADDRESS
❖ Click Query Wizard in the Queries group on the Create tab.
❖ Select Find Duplicates Query Wizard and press OK button.
❖ Select Table Employees and press Next.
❖ Select Address from Available Fields Press > and click Next Button to find the Employees
with same Address.
❖ Press >> and click Next button to show additional fields of Employees Table.
❖ Type name of query query_same_records in what do you want to name your query?
Text Box and click Finish.
❖ To run the query double-click query object query_same_records in Navigation Pane.
MS- Access Object Practical No. 09
Write a procedure or steps to create a table STUDENT having the following fields:
STD_ID, ST_NAME, CLASS, GROUP, GENDER
Queries.
1. Create STD_ID as Primary Key
2. Input 5 records
3. Find the list of female students
4. Find the list of male students
Procedure
1. Create a Database of Student
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Student in the file name text box
❖ Select location of the database and click Create button
2. Create Student table
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Std_Id and select Number from Data Type menu
❖ Right click Field Selector button and select Primary Key from menu.
❖ Add four more fields Std_Name , class , group and gender with data type Short Text of
all fields.
❖ Press Ctrl+s to save the table with Student name
3. Input 20 Records with different names
❖ Open the table object Student by double clicking in Navigation Pane and insert records
of 5 students of your choice according to data types.
4. Find the list of Female Students
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Student and click Add and
Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Std_id in first field, Std_name in second field, class in third field, group in fourth
field and gender in fifth field.
❖ Type ‘female’ in Criteria of gender field, so that only female students will appear.
❖ Press Ctrl+s to save the query with query name query_female.
❖ To run the query double-click query object query_female in Navigation Pane.
5. Find the list of Male Students.
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Student and click Add and
Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Std_id in first field, Std_name in second field, class in third field, group in fourth
field and gender in fifth field.
❖ Type ‘male’ in Criteria of gender field, so that only male students will appear.
❖ Press Ctrl+s to save the query with query name query_male.
❖ To run the query double-click query object query_male in Navigation Pane.
MS- Access Object Practical No. 10
Write a procedure or steps to create a table STUDENT having the following fields:
STUDENT_ID, STUDENT_NAME, ADDRESS, CELLNO
Queries.
1. Assign primary key to a suitable column.
2. Input 5 records
3. Display all records
4. Search only one record by STUDENT_ID
Procedure
1. Create a Database of Student
❖ Open MS-Access from program menu
❖ Click Blank Database
❖ Type name of database as Student in the file name text box
❖ Select location of the database and click Create button
2. Create Student table.
❖ Click Create tab
❖ Click Table Design button to open the design view.
❖ In Field Name type Student_Id and select Number from Data Type menu
❖ Right click Field Selector button and select Primary Key from menu.
❖ Add three more fields Student_Name , Address and Cellno with data types Short Text,
Long Text and Short Text respectively.
❖ Press Ctrl+s to save the table with Student name
3. Input 5 Records of students.
❖ Open the table object Student by double clicking in Navigation Pane and insert records
of 5 Students of your choice according to data types.
4. Display all records.
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table Student and click add and
Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select Student_id in first field, Student_name in second field, Address in third field and
cellono in fourth field.
❖ Press Ctrl+s to save the query with query name query_student.
❖ To run the query double-click query object query_student in Navigation Pane.
5. Search only one record by STUDENT_ID
❖ Click Query Design in the Queries group on the Create tab.
❖ The Show Table dialog box will appear and choose the table student and click add
and Close to close the Show Table dialog box.
❖ Select Select from Query Type group
❖ The Query Design screen will appear
❖ Select student_id in first field, student_name in second field, address in t third field
and cellno in fourth field.
❖ Type 1001 in Criteria of student_id field, to search that id.
❖ Press Ctrl+s to save the query with query name query_search.
❖ To run the query double click query object query_search in Navigation Pane.

You might also like