0% found this document useful (0 votes)
23 views45 pages

Xii Comp Practical Journal

Uploaded by

aqsee5046
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)
23 views45 pages

Xii Comp Practical Journal

Uploaded by

aqsee5046
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
You are on page 1/ 45

COMPUTER SCIENCE

PRACTICAL JOURNAL
FOR CLASS XII
PROGRAMMING IN C & MS ACCESS

Name: ____________________

Group: ____________________

Roll No.___________________

GOVT. DEGREE BOYS (SC/COM) COLLEGE (Morning)


GULISTAN – E – JAUHAR, KARACHI
CERTIFICATE

It is certified that Mr. _________________________________________,

Roll No. _______________________ has carried out all practical work as prescribed

by the Board of Intermediate Education Karachi, for the year 2023-2024.

Signature of Head of the Department

GOVT. DEGREE BOYS (SC/COM) COLLEGE (Morning)


GULISTAN–E–JAUHAR, KARACHI
Index
Programming in C
P# Object Remarks
1 Writing a Program that Prints a Text of Four Lines Consisting of
Characters, Integers and Floating Point Values Using printf Function.

2 Writing a Program that Reads & Prints the Data Using Escape Sequence
(Asking the Name, Age, Height and Gender of Student Using scanf and
printf Functions).
3 Writing a Program that Uses Operators (Calculate the Area of Triangle,
Volume of Sphere and Arrange The Resultant Values in Ascending Order).
4 Writing a Program that Uses ‘For’ Loop Statement. (Generate the
Multiplication Tables from 2 To 20).
5-A Writing a Program that Uses While Loop and Nested While Loop
• First While Loop Takes the Marks of each Individual Subject One
by One
• Second While Loop Validates the Marks Entered by the User and
Prompts the User to Input Correct Marks i.e. between 0 and 100
Unless User has Entered Correct Value of Marks
• Finally the Program Calculates the Average Marks of All Subjects
5-B Writing a Program that Uses For Loop and While Loop Inside For Loop to
Calculate Average Marks of Student:
Writing a Program that Uses While Loop and Nested While Loop
• The For Loop Takes the Marks of each Individual Subject One by
One
• Second While Loop Validates the Marks Entered by User and
Prompts User to Input Correct Marks i.e. Between 0 and 100
Unless User has Entered Correct Value of Marks
• Finally the Program Calculates the Average Marks of All Subjects
6 Writing a Program to Find the Factorial of Integer n Using ‘While’ Loop.
The Program Should Read the Value of n Using scanf and Print the
Factorial Using printf.
7-A Writing a Program to Draw Check-Board, the Program Should Use Nested
For Loops and If-Else Statement in Inner For Loop to Print the Result.
7-B Writing A Program to Calculate Fibonacci Series of Integer n Entered By
the User.
Note: Fibonacci Series is Defined as A Sequence of Numbers in Which the
First Two Numbers are 1 and 1, Or 0 and 1, Depending on the Selected
Beginning Point of the Sequence, and Each Subsequent Number is the
Sum of the Previous Two.
8 Writing a Program Which Uses a Switch Statement and Breaks the
Program if Certain Condition is Observed i.e. Writing a Program Which
Uses a Switch, Case And Break Statements and Interconvert the
Temperature Scales Using Menu Options.
9 Writing a Function that Generates Factorial of an Integer n and Calls this
Function in the ‘Main’ Program.
10 Writing a Program Which Uses Multiple Arguments in a Function.
(Develop a User-Defined Function to Generate a Rectangle. Use The
Function for Passing Arguments to Draw Different Sizes of Rectangles and
Squares).

MS ACCESS
01 Create database of student information
(ST_ID,NAME,CLASS, GROUP,SEX)
1. Create St_Id as primary key.
2. Input ten records.
Queries:
• Find the list of female students.
• Find the list of student.
02 Create database of library (Book_Id, name, reference or lending book
issued).
1. Create a suitable PK
2. input 10 records with difference names
Queries:
• Display list of books which are not for lending.
• Find list of books issued.
03 Create A Database In MS-Access Of Bank Accounts. Create 2 Tables,
Relationship B/W Tables.

1. Required fields of 1st table are Acct_Id, Acct_Name, Acct_


Address, Acct Phone, Acct_Enail.
2. Required fields of 2nd table are Acct_Id, Acct_Status.
Queries:
• Search the desired Acct_Id,
• Delete the desired Acct_Id
• update Desired Acct_Id.
04 Create a database in MS-Access of Students. Create 2 Tables, relationship
b/w tables.
1. Required fields of 1st table are Stud_Id, Stud_Name, Stud_
Address, Stud Phone, Stud_Enail.
2. Required fields of 2nd table are Stud_Id, Stud_Status.
Queries:
• Search the desired Stud_Id
• Delete the desired Stud_Id
• update Desired Stud_Id.
Page 1 of 41
Practical Journal Computer Science - XII

PROGRAMMING - C
PRACTICALS
Page 2 of 41
Practical Journal Computer Science - XII

Practical 1

Writing a Program that Prints a Text of Four Lines Consisting of Characters,


Integers and Floating Point Values Using printf Function.

Algorithm

Step 1. Write character.


Step 2. Write string.
Step 3. Write integer.
Step 4. Write floating point number.
Step 5. Exit.

Flowchart
Start

Write
character, string, integer,
floating point number

Stop

Source Code

#include<conio.h>
#include<stdio.h>
int main(void)
{
char ch = 'A', str[] = "My College";
int num = 2;
float fnum = 12.47;

printf("Character = %c\n", ch);


printf("String = %s\n", str);
printf("Integer = %d\n", num);
printf("float = %f\n", fnum);

return 0;
}

Output
Page 3 of 41
Practical Journal Computer Science - XII

Practical 2
Writing a Program that Reads & Prints the Data Using Escape Sequence
(Asking the Name, Age, Height and Gender of Student Using scanf and printf
Functions).

Algorithm
Step 6. Read gender.
Step 7. Read name.
Step 8. Read age.
Step 9. Read height.

Step 10. Write name.


Step 11. Write age.
Step 12. Write height.
Step 13. Write gender.
Step 14. Exit.

Flowchart Start

Read
gender, name, age,
height

Write
name, age, height,
gender

Stop

Source Code

#include<conio.h>
#include<stdio.h>
int main(void)
{
char gender, name[25];
int age;
float height;

printf("\nEnter Your Gender(M/F): ");


scanf("%c", &gender);
Page 4 of 41
Practical Journal Computer Science - XII
printf("\nEnter Your Name: ");
scanf("%s", name);
printf("\nEnter Your Age (in years): ");
scanf("%d", &age);
printf("\nEnter Your Height (in ft.): ");
scanf("%f", &height);
clrscr();
printf("\n\tName: %s", name);
printf("\n\tAge: %d", age);
printf("\n\tHeight: %0.2f", height);
printf("\n\tGender: %c", gender);

return 0;
}

Output
Page 5 of 41
Practical Journal Computer Science - XII

Practical 3

Writing a Program that Uses Operators (Calculate the Area of Triangle,


Volume of Sphere and Arrange The Resultant Values in Ascending Order).

Algorithm
1. Read a, b, r, t, s.
1
2. Set Area of Triangle t = a b.
2
4
Area of Sphere s =  r 3 .
3
3. IF t < s, then
Write t, s.
ELSE
Write s, t.
[End of IF-ELSE structure.]
4. Exit.

Flowchart

Start

Read
a, b, r, t, s

1
Area of Triangle t = a b
2
4 3
Area of Sphere s =  r
3

No
If t < s?

Yes

Write t, s Write s, t

Stop
Page 6 of 41
Practical Journal Computer Science - XII

Source Code

#include<stdio.h>
#include<conio.h>
#include<math.h>
#define pi 3.1415927
int main(void)
{
float a, b, r, t, s;
printf("\n\n\t\tEnter the value for Altitude of a Triangle. ");
scanf("%f", &a);
printf("\n\n\t\tEnter the value for Base of a Triangle. ");
scanf("%f", &b);
printf("\n\n\t\tEnter the value for Radius of a Sphere. ");
scanf("%f", &r);

t=(1.0/2.0)*(a*b);
s=(4.0/3.0)*pi*pow(r,3);
if (t<s)
{
printf("\n\n\t\tArea of Triangle = %.2f",t);
printf("\n\n\t\tArea of Sphere = %.2f",s);
}
else
{
printf("\n\n\t\tArea of Sphere = %.2f",s);
printf("\n\n\t\tArea of Triangle = %.2f",t);
}
return 0;
}

Output
Page 7 of 41
Practical Journal Computer Science - XII

Practical 4
Writing a Program that Uses ‘For’ Loop Statement to Generate the
Multiplication Tables from 2 To 20.

Algorithm

Step 15. Set j = 0.


Step 16. Read n.
Step 17. IF n >= 2 and n <= 20, then
Step 18. Repeat FOR i = 1 to 10
a. Set j = n  i.
b. Write j.
[End of FOR loop.]
Step 19. ELSE
Write Error!!! Enter number from 2 to 20.
[End of IF-ELSE structure.]
Step 20. Exit.

Flowchart

No
If i<=10?

Start
Yes

j=ni
j=0

Write j
Read n

i=i+1
If n>=2 and No
A
n<=20?
A
Yes

Write Error!!! Enter number from 2 to


i=1 20

Stop
Page 8 of 41
Practical Journal Computer Science - XII

Source Code

#include<stdio.h>
#include<conio.h>
int main (void)
{
int i,n,j=0;
printf("\n\t\tEnter Table No. ");
scanf("%d",&n);

if(n>=2 && n<=20)


for(i=1;i<=10;i++)
{
j=n*i;
printf("\n\t\t%d * %d = %d",n,i,j);
}
else
printf("\nError!!! Enter number from 2 to 20");

return 0;
}

Output
Page 9 of 41
Practical Journal Computer Science - XII

Practical 5(a)
Writing a Program that Uses While Loop and Nested While Loop
• First While Loop Takes the Marks of each Individual Subject One by
One
• Second While Loop Validates the Marks Entered by User and
Prompts User to Input Correct Marks i.e. Between 0 and 100 Unless
User has Entered Correct Value of Marks
• Finally the Program Calculates the Average Marks of All Subjects
Algorithm
Step 21. Set count = 1 and sum = 0.
Step 22. Read n. [number of subjects.]
Step 23. Repeat WHILE count  n
a. Read marks of n subjects.
b. Repeat WHILE marks are < 0 or > 100
i. Write Invalid marks, try again.
ii. Read marks.
[End of inner WHILE loop.]
c. sum = sum + marks.
d. count = count + 1.
[End of outer WHILE loop.]
Step 24. average = sum/n.
Step 25. Write average.
Step 26. Exit.
Page 10 of 41
Practical Journal Computer Science - XII

Flowchart Start

count=1, sum=0

Read n

If countn? No

Yes

Read
marks of n subjects

If
marks<0 or marks>100? No

Yes

Write
Invalid marks, try again

Read marks

sum=sum+marks

count=count+1

average=sum/n

Write average

Stop
Page 11 of 41
Practical Journal Computer Science - XII

Source Code

#include<stdio.h>
#include<conio.h>
int main(void)
{
int n, count = 1;
float marks, average, sum = 0;
// initialise and read in a value for n
printf("How many Subjects? ");
scanf("%d", &n);
printf("\n");
// read marks
while(count <= n)
{
printf("Marks in Subject %d = ", count);
scanf("%f", &marks);
while(marks < 0 ¦¦ marks > 100)
{
printf("Invalid marks, try again: ");
scanf("%f", &marks);
}
sum += marks;
++count;
}
// calculate the average and print the answer
average = sum/n;
printf("\nThe average marks are = %f", average);
return 0;
}

Output
Page 12 of 41
Practical Journal Computer Science - XII

Practical 5(b)
Writing a Program that Uses For Loop and While Loop Inside For Loop to
Calculate Average Marks of Student:
Writing a Program that Uses While Loop and Nested While Loop
• The For Loop Takes the Marks of each Individual Subject One by One
• Second While Loop Validates the Marks Entered by User and
Prompts User to Input Correct Marks i.e. Between 0 and 100 Unless
User has Entered Correct Value of Marks
• Finally the Program Calculates the Average Marks of All Subjects

Algorithm

Step 27. Set sum = 0.


Step 28. Read n. [number of subjects.]
Step 29. Repeat FOR count = 1 to n
e. Read marks of n subjects.
f. Repeat WHILE marks are < 0 or > 100
i. Write Invalid marks, try again.
ii. Read marks.
[End of WHILE loop.]
g. sum = sum + marks.
[End of FOR loop.]
Step 30. average = sum/n.
Step 31. Write average.
Step 32. Exit.
Page 13 of 41
Practical Journal Computer Science - XII

Flowchart

Start

sum=0

Read n

count=1

average=sum/n
If countn? No
1

Yes

Read Write average


marks of n subjects

If
marks<0 or marks>100? No

Stop

Yes

Write
Invalid marks, try again

Read marks

sum=sum+marks

count=count+1
Page 14 of 41
Practical Journal Computer Science - XII

Source Code

#include<stdio.h>
#include<conio.h>
int main(void)
{
int n, count;
float marks, average, sum = 0;
// initialise and read in a value for n
printf("How many Subjects? ");
scanf("%d", &n);
printf("\n");
// read marks
for(count =1; count <= n; count++)
{
printf("Marks in Subject %d = ", count);
scanf("%f", &marks);
while(marks < 0 ¦¦ marks > 100)
{
printf("Invalid marks, try again: ");
scanf("%f", &marks);
}
sum += marks;
}
// calculate the average and print the answer
average = sum/n;
printf("\nThe average marks are = %f", average);
return 0;
}

Output
Page 15 of 41
Practical Journal Computer Science - XII

Practical 6
Writing a Program to Find the Factorial of Integer n Using ‘While’ Loop. The
Program Should Read the Value of n Using scanf and Print the Factorial
Using printf.

Algorithm
Step 33. Set f = 1 and i = 1.
Step 34. Read num.
Step 35. IF num  0 then goto Step 4.
ELSE goto Step 6.
Step 36. Repeat WHILE i  num
h. f = f * i.
i. i = i + 1.
Step 37. Write f.
Step 38. ELSE
Write Sorry!!
Step 39. Exit.

Start
Flowchart

f = 1, i = 1

Read num

No
If num0?

Yes

Write
If inum? Sorry!!

Yes

f=f*i

i=i+1

Write f

Stop
Page 16 of 41
Practical Journal Computer Science - XII

Source Code

#include<stdio.h>
#include<conio.h>
int main(void)
{
double f=1;
int num, i;

printf("\n\n\n\t\tEnter the number to find its Factorial: ");


scanf("%d", &num);

if (num>=0)
{
i = 1;
while (i<=num)
{
f=f*i;
i++;
}
printf("\n\n\n\t\tThe factorial of %d is %lf", num, f);
}
else
printf("\n\n\n\t\t Sorry!!");
return 0;
}

Output
Page 17 of 41
Practical Journal Computer Science - XII

Practical 7(a)
Writing a Program to Draw Check-Board, the Program Should Use Nested
For Loops and If-Else Statement in Inner For Loop to Print the Result.
Algorithm

Step 40. Read a, b.


Step 41. Repeat FOR b = 1 to b < 12
Step 42. Repeat FOR a = 1 to a < 12
a. IF (a+b)(mod 2) = 0, then
Write \xDB.
b. ELSE
Write one blank space.
[End of IF-ELSE structure.]
[End of inner FOR loop.]
Write new line.
[End of outer FOR loop.]
Step 43. Exit.
Page 18 of 41
Practical Journal Computer Science - XII

Flowchart
Start

Read a, b

b=1

No
If b<12? Stop

Yes

a=1

No
If a<12?

Yes

If (a+b)(mod2)=0?
No

Yes

Write Write \xDB


one blank space

a=a+1

Write new
line

b=b+1
Page 19 of 41
Practical Journal Computer Science - XII

Source Code

#include<stdio.h>
#include<conio.h>
int main (void)
{
int a, b;

for(b=1; b<12; b++) /* stepping down */


{
for(a=1; a<12; a++) /* stepping right */
if((a+b)%2 == 0) /* even numbered square */
printf("\xDB"); /* print filled square */
else
printf(" "); /* print blank square */
printf("\n"); /* new line */
}

return 0;
}

Output
Page 20 of 41
Practical Journal Computer Science - XII

Practical 7(b)
Writing A Program to Calculate Fibonacci Series of Integer n Entered By the
User.
Note: Fibonacci Series is Defined as A Sequence of Numbers in Which the
First Two Numbers are 1 and 1, Or 0 and 1, Depending on the Selected
Beginning Point of the Sequence, and Each Subsequent Number is the Sum
of the Previous Two.

Algorithm

Step 1. Start
Step 2. Declare variables i, a,b , show
Step 3. Initialize the variables, a=0, b=1, and show =0
Step 4. Enter the number of terms of Fibonacci series to be printed
Step 5. Print First two terms of series
Step 6. Use loop for the following steps
show=a+b
a=b
b=show
increase value of i each time by 1
print the value of show
Step 7. End
Page 21 of 41
Practical Journal Computer Science - XII

if n==0:
return 0
elif n==1:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)

Flowchart
Page 22 of 41
Practical Journal Computer Science - XII

Source Code

#include <stdio.h>
int main() {
int i, n;
// initialize first and second terms
int t1 = 0, t2 = 1;
// initialize the next term (3rd term)
int nextTerm = t1 + t2;
// get no. of terms from user
printf("Enter the number of terms: ");
scanf("%d", &n);
// print the first two terms t1 and t2
printf("Fibonacci Series: %d, %d, ", t1, t2);
// print 3rd to nth terms
for (i = 3; i <= n; ++i) {
printf("%d, ", nextTerm);
t1 = t2;
t2 = nextTerm;
nextTerm = t1 + t2;
}
return 0;
}

Output
Page 23 of 41
Practical Journal Computer Science - XII

Practical 8
Writing a Program Which Uses a Switch Statement and Breaks the Program
if Certain Condition is Observed i.e. Writing a Program Which Uses a
Switch, Case And Break Statements and Interconvert the Temperature
Scales Using Menu Options.

Algorithm

Step 1. Read switch variable.


Step 2. IF switch variable = 1
j. Read c.
9
k. Convert Celsius to Fahrenheit using f = 32 + c.
5
IF switch variable = 2
l. Read f.
5
m. Convert Fahrenheit to Celsius using c = (f − 32) .
9
IF switch variable = 3
n. Read c.
o. Convert Celsius to Kelvin using k = c + 273.15 .
IF switch variable = 4
p. Read f.
5
q. Convert Fahrenheit to Kelvin using k = (f − 32) + 273.15 .
9
Step 3. ELSE
Write Invalid switch variable.
Step 4. Exit.
Page 24 of 41
Practical Journal Computer Science - XII

Flowchart
Start

Read
switch variable

case 1
from Celsius to Fahrenheit Yes Read 9
Yes c f = 32 + c
5

No

case 2
from Fahrenheit to Celsius Yes Read 5
Yes f c = (f − 32)
9

No

case 3
from Celsius to Kelvin Yes Read
Yes c k = c + 273.15

No

case 4
from Fahrenheit to Kelvin Yes Read 5
Yes f k = (f − 32) + 273.15
9

No

Write
Invalid switch variable

Stop
Page 25 of 41
Practical Journal Computer Science - XII

Source Code

#include<stdio.h>
#include<conio.h>
void main(void)
{
clrscr();
int i;
float c, f, k;
printf("\n\n\n");
printf("\t\t\tMENU FOR TEMPERATURE SCALE CONVERSION");
printf("\n\t\t\t_____________________________________\n\n");

printf("1. From Celsius to Fahrenheit scale\n");


printf("2. From Fahrenheit to Celsius scale\n");
printf("3. From Celsius to Kelvin scale\n");
printf("4. From Fahrenheit to Kelvin scale\n");
printf("\nEnter the MEMU option: ");
scanf("%d", &i);

switch(i)
{
case 1:
printf("Enter temperature in Celsius: ");
scanf("%f", &c);
f = 32.0+(9.0/5.0)*c;
printf("The temperature in Fahrenheit is = %.2f", f);
break;
case 2:
printf("Enter temperature in Fahrenheit: ");
scanf("%f", &f);
c = 5.0/9.0*(f-32.0);
printf("The temperature in Celsius is = %.2f", c);
break;
case 3:
printf("Enter temperature in Celsius: ");
scanf("%f", &c);
k = c + 273.15;
printf("The temperature in Kelvin is = %.2f", k);
break;
case 4:
printf("Enter temperature in Fahrenheit: ");
scanf("%f", &f);
k = (5.0/9.0*(f-32.0)) + 273.15;
printf("The temperature in Kelvin is = %.2f", k);
break;
default:
printf("Invalid MENU option\n\n");
}

getch();
}

Output
Page 26 of 41
Practical Journal Computer Science - XII

Practical 9
Writing a Function that Generates Factorial of an Integer n and Calls this
Function in the ‘Main’ Program.

Algorithm
Step 1. Declare a function double factorial(int x), which accepts an integer as an argument
and returns a double value.
The Function main
Step 2. Read num.
Step 3. IF num  0, then
Call the function factorial(num) and store the value it returns in fact.
(where num is the actual argument)
Write fact.
ELSE
Write Sorry!!
[End of IF-ELSE structure.]
Step 4. Exit.
Defining the Function double factorial(int x)
(where x is the formal argument)
Step 5. Set f = 1 and i = 1.
Step 6. Repeat FOR i =1 to i  x
f = f * i.
[End of FOR loop.]
Step 7. Return f.

Flowchart
Start factorial(int x)

f = 1, i = 1
Read num

No
If ix?
No
If num0?
Yes

Yes
f=f*i

fact = Write
call factorial(num) Sorry!!
i=i+1

Write fact

return(f)

Stop
Stop
Page 27 of 41
Practical Journal Computer Science - XII

Source Code

#include<stdio.h>
#include<conio.h>
double factorial(int x); /* function prototype */
void main(void)
{
clrscr();
int num;
double fact;
printf("\n\n\n\t\tEnter the number to find its Factorial: ");
scanf("%d", &num);

if (num>=0)
{
fact = factorial(num);
printf("\n\n\n\t\tThe factorial of %d is %lf", num, fact);
}
else
printf("\n\n\n\t\t Sorry!!");
getch();
}
double factorial(int x) /* factorial function */
{
int i;
double f=1;
for(i=1; i<=x; i++)
f=f*i;
return(f); /* return function */
}

Output
Page 28 of 41
Practical Journal Computer Science - XII

Practical 10
Writing a Program Which Uses Multiple Arguments in a Function. (Develop
a User-Defined Function to Generate a Rectangle. Use The Function for
Passing Arguments to Draw Different Sizes of Rectangles and Squares).

Algorithm

Step 1. Declare a function void rectangle(int, int), which accepts two integer arguments
but returns no value.
The Function main
Step 2. Write Drawing room.
Step 3. Call function rectangle(6,3).
(6 and 3 are length and width of the room)
Step 4. Write Bedroom.
Step 5. Call function rectangle(8,2).
Step 6. Write Bathroom.
Step 7. Call function rectangle(2,1).
Step 8. Write Kitchen.
Step 9. Call function rectangle(4,3).
Step 10. Exit.
Defining the Function void rectangle(int length, int width)
Step 11. Repeat FOR j = 1 to j <= width
Step 12. Repeat FOR k = 1 to k <= length
Write \xDB.
(where \xDB is the code for one rectangle)
[End of inner FOR loop.]
Write new line.
[End of outer FOR loop.]
Step 13. Exit.
Page 29 of 41
Practical Journal Computer Science - XII

Flowchart

Start rectangle(int length, int width)

Write Drawing room j=1

call function
rectangle(6,3) No
Stop If j<=width?

Write Yes j=j+1


Bedroom

k=1

call function Write


rectangle(8,2) new line

No
If k<=length?
Write Bathroom

Yes

call function
rectangle(2,1) Write
\xDB

Write Kitchen
k=k+1

call function
rectangle(4,3)

Stop
Page 30 of 41
Practical Journal Computer Science - XII

Source Code

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

void rectangle(int length, int width); /* function prototype */

int main(void)
{
printf("\nDrawing room\n"); /* print room name */
rectangle(6,3); /* draw room */
printf("\nBedroom\n"); /* etc. */
rectangle(8,2);
printf("\nBathroom\n");
rectangle(2,1);
printf("\nKitchen\n");
rectangle(4,3);
return 0;
}

/* function draws rectangle of particular length and width */


void rectangle(int length, int width)
{
int j,k;
for(j=1; j<=width; j++) /* number of lines */
{
for(k=1; k<=length; k++) /* line of rectangles */
printf("\xDB"); /* print one rectangle */
printf("\n"); /* new line */
}
}

Output
Page 31 of 41
Practical Journal Computer Science - XII

MS-Access
PracticalS
Page 32 of 41
Practical Journal Computer Science - XII

Practical # 01

Create Database of Student Information


(ST_ID,NAME,CLASS, GROUP,SEX)

1. Create St_Id as primary key.


2. Input ten records.
Queries:

• Find the list of female students.


• Find the list of student.
Procedure

Creating Database

1. Click File from menu bar and click New. Click the blank Database
2. Write the file name for Database in file name Box e.g. Students.
Crating Table

3. Click Table button from Object Panel from Database widow.


4. Double click “Create Table in Design View” from three given options.
A window appears with three columns Field Name, Data type,
Description.

Entering Fields:

1. Type St_id in first field name & press Tab key to switch to next column
with heading Data Type . A list triangle appears.

2. Click list triangle and select a data type for St_id from the list i-e text.
3. Press Tab key to go Description column of and gives comments about
the field (optional).
4. Repeat step (a) to (c) for giving other fields e.g. St- Name, St-Class, St-
Group, St-Sex.
5. Right click the field “St-id”. A context menu appears click the Primary
Key from this menu. It will set the Primary Key for St-id Field.
6. Click save button or press CTRL+S. Save as dialog box appears.
7. Type table name Table1, and click ok. Click close button.
Page 33 of 41
Practical Journal Computer Science - XII

Entering Records:

8. Double Click Table1 in Data base window. A window appears. Enter


records here.
9. Press CTRL+S to save records. Click close button.
Queries

• Searching Record (By Design View)


1. Click Queries button in objects panel.
2. From the Queries page on the Database window, double click
Create in Design View. Show Table dialog box opens.
3. Click Table1 click Add button. And click Close button to close Show
Table Dialog box. Tow selected tables appear in boxes in select
query window.
4. Click in first column Double click the list triangle, click the field St
_Id.
OR

Double click field St_ Id from Table Box

Repeat step 4 and add St_Class St_ Group, St _ Sex from Table1.

5. In column containing St _ Sex field, click in criteria cell. Type


Female to see record no of Female Sex.
6. Click Run button on tool bar or choose Query, Run. A query is
performed and female Sex records are display in a table.
7. Press CTRL+S to save the query.
8. In dialog box enter a name for Query1. And click ok.

• Searching List of Student query (Design View):


9. repeat step 1 to 3
10. Repeat step 5 to display requested query. It shows the list of all
students.
Repeat step 6 to save the query with another name e.g Query 2.
Page 34 of 41
Practical Journal Computer Science - XII

Practical # 02

Create database of Library (Book_Id, name, reference or


lending book issued).
1. Create a suitable PK
2. input 10 records with difference names
Queries
• Display list of books which are not for lending.
• Find list of books issued.

Procedure

Creating database

1. Click File from menu bar and click New. Click the blank Database.
2. Write the file name for Database in file name Box e.g. Library

Creating Table

3. Click Table button from Object panel from database window.


4. Double click ‘Create Table in Design View” from three given
option.
A window appears with three columns Field name, data type
Description.

Entering Fields

a) Type book _ id in first field name & press Tab key to switch to next
column witth heading Data type. A list triangle appears
b) Click list triangle and select a data type for book _ id from the list.
c) Press tab key to go to Description column of the particular field.
(Just comments).
Repeat step (a) to (c) for given other fields e.g. Book _name, Book
reference or lending book.

5. Right click the field “Book_ id’. A context menu appears click the
primary Key from this menu. It will set the Primary Key for Book-
id field.
6. Click save button. Or press CtrI + S, save as dialog box appear.
7. Type table name Table! And click OK. Click Close button.
Page 35 of 41
Practical Journal Computer Science - XII

Enter Record

8. Click save table1 in data base window. Click view menu then Click
datasheet View. A window appears. Enter record here
9. Press CTRL+ S to save record. Click Close button.

Queries

Searching Record (By Design View).

1. Click Queries button in objects panel.


2. From the queries page on the Database Window. Double-click Create
In Design View. Show Table dialog box opens.
Click Table 1 click Add button. And click Close button to close Show
Table Dialog Box. Two selected tables appear in boxes in select query
window.

3. Click in next column. Double click the field Book-Id from Table1 Box.
4. Click in next column. Double click the field Book-Name from Table1
box.
5. Repeat step4 and add Book- Reference/ Lending. Book-issued from
Table1.
6. In column containing Book-Reference/Lending. Book-field, click in
criteria cell. Type Female to see record no of Book-Reference/Lending.
Book-issued.

7. Click Run ! button on tool bar or choose Query, Run. A query is


performed and issued books-reference/Lending records are displays
in a table.
8. Press CTRL+S top save the query.

Searching All Issued Books (By Design view):

9. Repeat step from 1 to3.


10. Repeat step 5 to display requested query. It shows the list of all
students.
Repeat step 6 to save the query with another name e.g. Query 2.
Page 36 of 41
Practical Journal Computer Science - XII

Practical # 3

Create A Database In MS-Access Of Bank Accounts.


Create 2 Tables, Relationship B/W Tables.
1. Required fields of 1st table are Acct_Id, Acct_Name, Acct_ Address,
Acct Phone, Acct_Email.
2. Required fields of 2nd table are Acct_Id, Acct_Status.
Queries
• Search the desired Acct_Id,
• Delete the desired Acct_Id
• update Desired Acct_Id.

Procedure

Creating Database

1. Click File from menu bar and click New. Click the Blank database.
2. Write the file name for database in file name box.e.g. Bank-account.

Creating Tables

3. Click Table button from Object Panel from database windows.


4. Double click “Create Table in design view” from there given option

A window appears with three columns Filed Name, Data type, Description.

Entering Fields:

a) Type Acct_Id in first field name & Press Tab Key to switch to next column
with heading Data Type. A list triangle appears
b) Click list triangles and select a Data Type for Acct_ id from the list.
c) Press Tab Key to go to Description column of the particular field.(just
Comments)

Repeat step (a) to (c) for creating other fields.

5. Right click the field “Account_Id”. A context menu appears click the Primary
Key from this menu. It will set the Primary Key for Acct_Id Field.
Page 37 of 41
Practical Journal Computer Science - XII

6. Click save button or press CTRL+S. Save as dialog box appears.


7. Type table name Table1, and Click ok. Click Close button.
Repeat step 4 to step 7 and create second table with acct Id, Acct Id Field

Save it with name Table2.

Entering Records:-

1. Click Table1 in data base window. Click view menu then datasheet view.
A window appears. Enter record here.
2. Press CTRL+S to save records .Click Close button.

Repeat step 1 to 2 of C option for entering data in Table2.

Creating Relationship between Tables

1. Close Table1 and Table2 by clicking X button.


2. Click Tool menu then click Relationship from Pull down menu.
A window with title Relationship appears.

3. Click Relationship from menu bar then click Show Table. All tables
created in opened database appear in show table Box.
4. Select Table1 & click Add button. Click Table2 & click Add. Then click
Close button.
5. The two boxes of Table1 and Table2 appear with their fields.
6. Click Acct-ld field of Table1, drag the mouse till Acct-id field of Table2.
7. Click Enforce Referential integrity then click Create button.
A relationship line between two tables appears showing that a
relationship is created.

8. Save relationship by pressing CTRL+S. And close the relationship


window.

Queries:

• Searching and editing Record


Query (By Design View)

1. Click Queries button in objects panel.


2. From the Queries page on the Database Window, Double-click Create in
Design View. Show Table dialog box opens.
3. Click Table1 Click Add button. Then Click Table2 and Click Add. And click
Close button to close Show Table Dialog Box. Two selected tables appear
in boxes in select query window.
4. Click in first column. Double click the field Acct-Id from Table box.
Repeat step 4 and add Acct_Phone, Acct_Address, Acct_Email, from Table1
and Acct_status from Table2
Page 38 of 41
Practical Journal Computer Science - XII

5. In column containing Acct-id field, click in criteria cell. Type 3 to see


record no.3.
6. Click Run button on tool bar or choose Query, Run . A query is
performed and record no 3 displays in a table.
7. Press CTRL+S to save the query.
8. In dialog box enter a name for query1. And click ok.

• Deleting Desired Record:

1. In database window double click Table1 to open it.


2. Click filter click advance filter /sort. The table1 list filter 1 windows
opens
3. Click filed box and Click list triangle. Select acct_id by which a record is to
searched.
4. Click criteria type rec no.
5. Click filter click apply filter sort.
6. It will show the searched record.
7. Click gray button to the left of record press delete from keyboard.

• Updating Desired Record:-


8. The appeared record can be edited here by typing.
Page 39 of 41
Practical Journal Computer Science - XII

Practical # 4

Create a database in MS-Access of Students. Create 2


Tables, relationship b/w tables.
1. Required fields of 1st table are Stud_Id, Stud_Name, Stud_ Address,
Stud Phone, Stud_Email.

2. Required fields of 2nd table are Stud_Id, Stud_Status.

Queries
• Search the desired Stud_Id
• Delete the desired Stud_Id
• update Desired Stud_Id.

Procedure

Creating Database

1. Click File from menu bar and click New. Click the Blank database.
2. Write the file name for database in file name student .e.g. student_att.

Creating Table

3. Click Table button from Object Panel from database windows.


4. Double click “Create Table in design view” from there given option

A window appears with three columns Filed Name, Data type, Description.

Entering Fields:

a) Type Stud_Id in first field name & Press Tab Key to switch to next
column with heading Data Type. A list triangle appears
b) Click list triangles and select a Data Type for Stud_ id from the list.
c) Press Tab Key to go to Description column of the particular
field.(just Comments)

Repeat step (a) to (c) for creating other fields.

5. Right click on the field “Student_Id”. A context menu appears click the
Primary Key from this menu. It will set the Primary Key for Stud-Id Field.
6. Click save button or press CTRL+S. Save as dialog box appears.
7. Type table name Table1, and Click ok. Click Close button.
Repeat step 4 to step 7 and create second table with Stud Id, Stud Id Field
Page 40 of 41
Practical Journal Computer Science - XII

Save it with name Table2.

Entering Records:-

1. Click Table1 in data base window. Click view menu then datasheet view.
A window appears. Enter record here.
2. Press CTRL+S to save records .Click Close button.
Repeat step 1 to 2 of C option for entering data in Table2.

Crating Relationship between Tables

1. Close Table1 and Table2 by clicking X button.


2. Click Tool menu then click Relationship from Pull down menu.
A window with title Relationship appears.

3. Click Relationship from menu bar then click Show Table. All tables
created in opened database appear in show table Box.
4. Select Table1 & click Add button. Click Table2 & click Add. Then click
Close button.
5. The two boxes of Table1 and Table2 appear with their fields.
6. Click Stud-ld field of Table1, drag the mouse till Stud-id field of Table2.
7. Click Enforce Referential integrity then click Create button.
A relationship line between two tables appears showing that a
relationship is created.

8. Save relationship by pressing CTRL+S. And close the relationship


window.

Queries

Searching and editing Record

Query (By Design View)

1. Click Queries button in objects panel.


2. From the Queries page on the Database Window, Double-click Create in
Design View. Show Table dialog box opens.
3. Click Table1 Click Add button. Then Click Table2 and Click Add. And click
Close button to close Show Table Dialog Box. Two selected tables appear
in boxes in select query window.
4. Click in first column. Double click the field Stud-Id from Table box.
Repeat step 4 and add Stud_Phone, Stud_Address, Stud_Email, from
Table1 and Stud_status from Table2

5. In column containing Stud_id field, click in criteria cell. Type 3 to see


record no3.
6. Click Run button on tool bar or choose Query, Run. A query is performed
and record no 3 displays in a table.
7. Press CTRL+S to save the query.
Page 41 of 41
Practical Journal Computer Science - XII

8. In dialog box enter a name for query1. And click ok.

• Deleting Desired Record


1. In database window double click Table1 to open it.
2. Click filter click advance filter /sort. The table1 list filter 1 windows
open
3. Click filed box and Click list triangle. Select Stud_id by which a record
is to search.
4. Click criteria type rec no. is to searched.
5. Click filter click apply filter sort.
6. It will show the searched record.
7. Click gray button to the left of record press delete from keyboard.

• Updating Desired Record


8. The appeared record can be edited here by typing.

You might also like