Computer Science Practical File
Computer Science Practical File
SCIENCE
PRACTICAL FILE
CLASS XII - A
2. 25 SQL QUERIES
OUTPUT :
COMPUTER
SCIENCE
PROJECT FILE
CLASS XII - A
2. CERTIFICATE
3. PROGRAM CODE
4. OUPUT
5. RESOURCES USED
ACKNOWLEDGEMENT
Signature : xxxxxx
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 :
#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");
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();
getch();
}
OUTPUT 24:
PROGRAM 25 :
# include<stdio.h>
#include<iostream.h
>#include<conio.h>
void main()
int c;
void func1();
void func2();
void func3();
void func4();
void func5();
clrscr();
printf("\n-------------------------------------");
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]);
clrscr();
getmatrix(x);
getmatrix(y);
addition(x,y,z);
display(x);
display(y);
display(z);
int i,j;
for(i=0;i<3;i++)
for(j=0;j<3;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];
clrscr();
getmatrix(x);
getmatrix(y);
subtraction(x,y,z);
display(x);
display(y);
display(z);
{
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];
clrscr();
getmatrix(x);
getmatrix(y);
multiplication(x,y,z);
display(x);
display(y);
display(z);
{
int i,j,k;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
//condition i< total col of matrix1 or//condition i< total row of matrix2
r[i][j]=0;
r[i][j]=r[i][j]+(p[i][j]*q[j][k]);
void func4()
int x[3][3],y[3][3];
clrscr();
getmatrix(x);
transpose(x,y);
display(x);
display(y);
}
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];
clrscr();
getmatrix(x);
transpose(x,y);
if(symmetric(x,y)==1)
printf("\nMatrix is Symmetric");
else
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;
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 :