Computer Practical
Computer Practical
Computer Practical
2021-2022
Certificate
Date:____________
____________________
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
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();
scanf("%d%d%d",&a,&b,&c);
d=pow(b,2)-(4*a*c);
if(d<0)
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>
float a,b,r,t,s;
scanf(“%f”,&a);
scanf(“%f”,&b);
scanf(“%f”,&r);
t= (1.0/2.0)*a*b;
s= (4.0/3.0)*(22/7)*pow(r,3);
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();
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();
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();
scanf("%d",&year);
if(year%4==0)
else
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();
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
total=a+b+c+d+e;
per=(total/500.0)*100;
if(per>=90||per>=80)
else if(per>=70&&per<=79)
printf("\nThe grade is A");
else if(per>=60&&per<=69)
else if(per>=50&&per<=59)
else if(per>=40&&per<=49)
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();
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;
scanf("%d",&a);
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();
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();
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();
scanf(“%d”,&a);
for(i=1;i<=a;i++)
f=f*i;
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();
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();
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>
int number;
int n;
number=1;
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>
return(x*x*x);
int n, k;
clrscr();
scant(“%d” , &n);
k = cube (n);
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;
else if(x>=97&&x<=122)
x=x-32;
else
void main(void)
{
char a;
clrscr();
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++)
scanf("%d",&arr[i]);
}
printf("\nEnter a number whose find it: ");
scanf("%d",&search);
for(i=0;i<=9;i++)
if(search==arr[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++)
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;
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();
for(i=2;i<n;i++)
if(n%i==0)
flag=1;
break;
if(flag==0)
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();
Scanf(“%f%f%f%f%f%f%f”,&m,&t,&w,&th,&f,&st,&s);
average=(m+t+w+th+f+st+s)/7;
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();
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("\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:
Source code:
#include<stdio.h>
#include<conio.h>
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();
scanf(“%d”,&a);
f=fact(a);
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)
scanf("%d", &rows);
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();
scanf("%d%d",&a,&b);
x=a;
y=b;
while(a!=b)
if(a>b)
a=a-b;
else
b=b-a;
gcd=b;
lcm=(x*y)/gcd;
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.
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 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.