0% found this document useful (0 votes)
103 views

Computer Science Practical File

This document contains a computer science project file created by Rahil Ali Khan of class XII-A. The file includes 25 C++ programs, 25 SQL queries, and acknowledgments. It was created using Windows 7, Turbo C7 IDE, and Notepad text editor for the library management system project.

Uploaded by

Rahil Ali Khan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views

Computer Science Practical File

This document contains a computer science project file created by Rahil Ali Khan of class XII-A. The file includes 25 C++ programs, 25 SQL queries, and acknowledgments. It was created using Windows 7, Turbo C7 IDE, and Notepad text editor for the library management system project.

Uploaded by

Rahil Ali Khan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

COMPUTER

SCIENCE
PRACTICAL FILE

RAHIL ALI KHAN

CLASS XII - A

ROLL NUMBER - 1111111


INDEX
1. 25 C++ PROGRAMS

2. 25 SQL QUERIES
OUTPUT :
COMPUTER
SCIENCE
PROJECT FILE

RAHIL ALI KHAN

CLASS XII - A

ROLL NUMBER - 1111111


INDEX
1. ACKNOWLEDGEMENT

2. CERTIFICATE

3. PROGRAM CODE

4. OUPUT

5. RESOURCES USED
ACKNOWLEDGEMENT

I would like to thank all those who have


helped me in completing this project on

“LIBRARY MANAGEMENT SYSTEM”

I sincerely acknowledge my gratitude to


my colleague who helped me in
completing the project by giving
interesting ideas, thoughts and made this
project easy and accurate

Also I am thankful to our computer


science faculty Ms.Pooja Dhingra for her
constant help at various stages
CERTIFICATE

This is to certify that Rahil Ali Khan of


class XII-A Salwan public school , Delhi

successfully completed his project on


LIBRARY MANAGEMENT SYSTEM in the
year 2017-2018 under the guidance of
Ms.Pooja Dhingra

Signature : xxxxxx

(computer science faculty)


RESOURCES USED

OPERATING SYSTEM : WINDOWS 7

C++ IDE : TURBO C7 By AKKI

TEXT EDITOR : NOTEPAD


PROGRAM 21 :

Write a menu driven program which allows the user to perform the following
functions on a: Insert ,Delete,Display and Exit

include<stdio.h>
#include<stdlib.h>
#define max_size 5
int queue[max_size],front=-1,rear=-1;

void insert();
void del();
void display();

int main()
{
int choice;
do{

printf("\n\n--------QUEUE OPERATIONS-----------\n");
printf("1.Insert\n");
printf("2.Delete\n");
printf("3.Display\n");
printf("4.Exit\n");
printf("-----------------------");
printf("\nEnter your choice:\t");
scanf("%d",&choice);
switch(choice)
{
case 1:
insert();
break;
case 2:
del();
break;
case 3:
display();
break;
case 4:
exit(0);
break;
default:
printf("\nInvalid choice:\n");
break;
}
}while(choice!=4);
return 0;
}
void insert() //Inserting an element in to the queue
{
int item;
if(rear==(max_size-1))
{
printf("\nQueue Overflow:");
}
else
{
printf("Enter the element to be inserted:\t");
scanf("%d",&item);
rear=rear+1;
queue[rear]=item;

if(front==-1)
front=0;
}

}//end of insert()
void del() //deleting an element from the queue
{
int item;
if(front==-1)
{
printf("\nQueue Underflow:");
}
else
{
item=queue[front];
printf("\nThe deleted element: %d\t",item);
if(front==rear)
{
front=-1;
rear=-1;
}
else
{
front=front+1;
}
}
}//end of del()
void display() //To display the queue elements
{
int i;
if(front==-1)
{
printf("\nQueue is Empty:");
}
else
{
printf("\nThe queue elements are:\n" );
for(i=front;i<=rear;i++)
{
printf("%d\t",queue[i]);
}
}

OUTPUT 21:

PROGRAM 22 :

Write a menu driven program which allows the user to perform the following
operations on a stack :Push,Pop,Display and Exit

#include<stdio.h>
#include<stdlib.h>
#define max_size 5
int stack[max_size],top=-1;

void push();
void pop();
void peep();
void display();

int main()
{
int choice;
do{
//printf("\n");
printf("\n\n--------STACK OPERATIONS-----------\n");
printf("1.Push\n");
printf("2.Pop\n");
printf("3.Peep\n");
printf("4.Display\n");
printf("5.Exit\n");
printf("-----------------------");
printf("\nEnter your choice:\t");
scanf("%d",&choice);
switch(choice)
{
case 1:
push();
break;
case 2:
pop();
break;
case 3:
peep();
break;
case 4:
display();
break;
case 5:
exit(0);
break;
default:
printf("\nInvalid choice:\n");
break;
}
}while(choice!=5);
return 0;
}
void push() //Inserting element in to the stack
{
int item;
if(top==(max_size-1))
{
printf("\nStack Overflow:");
}
else
{
printf("Enter the element to be inserted:\t");
scanf("%d",&item);
top=top+1;
stack[top]=item;
}
}
void pop() //deleting an element from the stack
{
int item;
if(top==-1)
{
printf("Stack Underflow:");
}
else
{
item=stack[top];
top=top-1;
printf("\nThe poped element: %d\t",item);
}
}
void peep()
{
if(top==-1)
{
printf("\nStack is empty:");
}
else
{
printf("The topmost element of the stack is %d",stack[top]);
}
}
void display()
{
int i;
if(top==-1)
{
printf("\nStack is Empty:");
}
else {
printf("\nThe stack elements are:\n" );
for(i=top;i>=0;i--)
{
printf("%d\n",stack[i]);
}
}

OUTPUT 22:

PROGRAM 23 :

Sorting array in ascending and descending order

#include <stdio.h>

int main(void)
{
int a[10], i=0, j=0, n, t;
printf ("\n Enter the no. of elements: ");
scanf ("%d", &n);
printf ("\n");

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


{
printf ("\n Enter the %dth element: ", (i+1));
scanf ("%d", &a[i]);
}

for (j=0 ; j<(n-1) ; j++)


{
for (i=0 ; i<(n-1) ; i++)
{
if (a[i+1] < a[i])
{
t = a[i];
a[i] = a[i + 1];
a[i + 1] = t;
}
}
}

printf ("\n Ascending order: ");


for (i=0 ; i<n ; i++)
{
printf (" %d", a[i]);
}

printf ("\n Descending order: ");


for (i=n ; i>0 ; i--)
{ printf (" %d", a[i-1]);
}

/* indicate successful completion */


return 0;
OUTPUT 23:

PROGRAM 24 :

Write a function in C++ which accepts an integer array and its size as
arguments/parameters and exchanges the values of first half side elements
with the second half side elements of the array.

#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();

int a[10], temp,i=0;


for( i=0;i<10;i++)
{ cout<<" Enter Value for "<<i+1<<" element: ";
cin>>a[i];
}

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


{ temp=a[i];
a[i]=a[5+i];
a[5+i]=temp;
}
cout<<"Array: ";
for(i=0;i<10;i++)
{ cout<<" "<<a[i];
}

getch();
}
OUTPUT 24:

PROGRAM 25 :

Write down a menu driven c program to perform the following matrix


operation on a 3 x 3 matrix.
Matrix Addition.
Matrix Subtraction.
Matrix Multiplication.
To find Transpose of a matrix.
To find out if the matrix is symmetric or not.

# include<stdio.h>

#include<iostream.h
>#include<conio.h>

void display(int [][3]);

void main()

int c;

void func1();

void func2();

void func3();

void func4();

void func5();

clrscr();

printf("\n- : Matrix Manipulation Functions (for 3 X 3 Matrix) : -");

printf("\n-------------------------------------");

printf("\n Matrix Addition : 1");

printf("\n Matrix Subtraction : 2");

printf("\n Matrix Multiplication : 3");

printf("\n Find Transpose Matrix : 4");

printf("\n Matrix is Symmetric or not : 6");

printf("\n Enter Your Choice : ");

scanf("%d",&c);

switch(c)

case 1:

func1();
break;

case 2:

func2();

break;

case 3:

func3();

break;

case 4:

func4();

break;

case 5:

func5();

break;

default:

printf("\nInvalid Choice");

getch();

void func1()

int x[3][3],y[3][3],z[3][3];
void getmatrix(int [][3]);

void addition(int [][3],int [][3],int [][3]);

clrscr();

getmatrix(x);

getmatrix(y);

addition(x,y,z);

printf("\n - : Matrix 1: - \n");

display(x);

printf("\n - : Matrix 2: - \n");

display(y);

printf("\n - : Matrix Addition (Result): - \n");

display(z);

void getmatrix(int t[][3])

int i,j;

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

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

printf("Enter element [%d][%d] : ",i,j);

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

}
void addition(int p[][3],int q[][3],int r[][3])

{ int i,j;

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

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

r[i][j]=p[i][j]+q[i][j];

void func2()

int x[3][3],y[3][3],z[3][3];

void getmatrix(int [][3]);

void subtraction(int [][3],int [][3],int [][3]);

clrscr();

getmatrix(x);

getmatrix(y);

subtraction(x,y,z);

printf("\n - : Matrix 1: - \n");

display(x);

printf("\n - : Matrix 2: - \n");

display(y);

printf("\n - : Matrix Subtraction (Result): - \n");

display(z);

void subtraction(int p[3][3],int q[3][3],int r[3][3])

{
int i,j;

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

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

r[i][j]=p[i][j]-q[i][j];

void func3()

int x[3][3],y[3][3],z[3][3];

void getmatrix(int [][3]);

void multiplication(int [][3],int [][3],int [][3]);

clrscr();

getmatrix(x);

getmatrix(y);

multiplication(x,y,z);

printf("\n - : Matrix 1: - \n");

display(x);

printf("\n - : Matrix 2: - \n");

display(y);

printf("\n - : Matrix Multiplication (Result): - \n");

display(z);

void multiplication(int p[][3],int q[3][3],int r[3][3])

{
int i,j,k;

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

//condition i< total row of matrix1

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

//condition i< total col of matrix1 or//condition i< total row of matrix2

r[i][j]=0;

for(k=0;k<3;k++) //condition i< total col of matrix2

r[i][j]=r[i][j]+(p[i][j]*q[j][k]);

void func4()

int x[3][3],y[3][3];

void getmatrix(int [][3]);

void transpose(int [][3],int [][3]);

clrscr();

getmatrix(x);

transpose(x,y);

printf("\n - : Matrix 1: - \n");

display(x);

printf("\n - : Transpose Matrix : - \n");

display(y);
}

void transpose(int p[][3],int q[][3])

int i,j;

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

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

q[i][j]=p[j][i];

void func5()

int x[3][3],y[3][3];

void getmatrix(int [][3]);

void transpose(int [][3],int [][3]);

int symmetric(int [][3],int [][3]);

clrscr();

getmatrix(x);

transpose(x,y);

if(symmetric(x,y)==1)

printf("\nMatrix is Symmetric");

else

printf("\nMatrix is Not Symmetric");

int symmetric(int p[][3],int q[][3])


{

int i,j;

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

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

if(q[i][j]!=p[i][j])

return 0;

return 1;

void display(int m[][3])

int i,j;

printf("\n\n");

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

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

printf("%d ",m[i][j]);

printf("\n");

}
OUTPUT 25 :

You might also like