The journey of self-motivation and personal growth is a lifelong path, filled with twists and turns, triumphs and setbacks. By embracing this journey, we can develop the skills, confidence, and resilience needed to achieve our goals and live a fulfilling life. I hope that my insights and experiences will inspire and motivate you to embark on your own journey of self-discovery and growth.Join me as I share insights, experiences, and practical tips on living a fulfilling life.
Monday, April 20, 2015
Tuesday, April 7, 2015
C program for parenthesized expression using stack
/*PARENTHESIZED EXPRESSION USING STACK */
#include<stdio.h>
#include<conio.h>
#define MAX 10
int top=-1;
int stack[MAX];
void push(char);
char pop();
void main()
{
char exp[MAX],ch;
int i,flag=1;
clrscr();
printf("\n Enter Infix Expression:-\n");
gets(exp);
i=0;
while(exp[i]!='\0')
{
if(exp[i]=='('||exp[i]=='{'||exp[i]=='[')
{
push(exp[i]);
}
if(exp[i]==')'||exp[i]=='}'||exp[i]==']')
{
ch=pop();
if(exp[i]==')'&&(ch=='{'||ch=='['))
{
flag=0;
}
if(exp[i]=='}'&&(ch=='('||ch=='['))
{
flag=0;
}
if(exp[i]==']'&&(ch=='('||ch=='{'))
{
flag=0;
}
}
i++;
}
if(top>=0)
{
flag=0;
}
if(flag==1)
{
printf("\n Valid Expression");
}
else
{
printf("\n Invalid Expression");
}
getch();
}
void push(char c)
{
if(top==MAX-1)
{
printf("\n stack is full");
}
else
{
top++;
stack[top]=c;
}
}
char pop()
{
char c;
if(top==-1)
{
printf("\n Stack is empty");
}
else
{
c=stack[top];
top--;
return c;
}
}
#include<stdio.h>
#include<conio.h>
#define MAX 10
int top=-1;
int stack[MAX];
void push(char);
char pop();
void main()
{
char exp[MAX],ch;
int i,flag=1;
clrscr();
printf("\n Enter Infix Expression:-\n");
gets(exp);
i=0;
while(exp[i]!='\0')
{
if(exp[i]=='('||exp[i]=='{'||exp[i]=='[')
{
push(exp[i]);
}
if(exp[i]==')'||exp[i]=='}'||exp[i]==']')
{
ch=pop();
if(exp[i]==')'&&(ch=='{'||ch=='['))
{
flag=0;
}
if(exp[i]=='}'&&(ch=='('||ch=='['))
{
flag=0;
}
if(exp[i]==']'&&(ch=='('||ch=='{'))
{
flag=0;
}
}
i++;
}
if(top>=0)
{
flag=0;
}
if(flag==1)
{
printf("\n Valid Expression");
}
else
{
printf("\n Invalid Expression");
}
getch();
}
void push(char c)
{
if(top==MAX-1)
{
printf("\n stack is full");
}
else
{
top++;
stack[top]=c;
}
}
char pop()
{
char c;
if(top==-1)
{
printf("\n Stack is empty");
}
else
{
c=stack[top];
top--;
return c;
}
}
C program in stack to concatenate two strings using push and pop functions
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max 30
void push(char ch);
char pop();
char stack[max];
int top=-1;
void main()
{
char a[20],b[20],k[40],ch;
int i,l1,l2;
clrscr();
printf("\n Enter First String:-\n");
scanf("%s",a);
printf("\n Enter Second String:-\n");
scanf("%s",b);
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l2;i++)
{
push(b[i]); //push second string into stack
}
push(' ');
for(i=0;i<l1;i++)
{
push(a[i]); //push first string into stack
}
printf("\n After concatenation of two string:-\n");
i=0;
while(top!=-1)
{
ch=pop();
if(ch==' ')
{
k[i]='\0';
printf("%s",strrev(k));
i=0;
}
else
{
k[i]=ch;
i++;
}
}
k[i]='\0';
printf("%s",strrev(k));
getch();
}
void push(char ch)
{
if(top==max-1)
{
printf("\n Stack is full");
}
else
{
top++;
stack[top]=ch;
}
}
char pop()
{
char t;
if(top==-1)
{
printf("\n Stack is Empty");
}
else
{
t=stack[top];
top--;
return(t);
}
}
#include<conio.h>
#include<string.h>
#define max 30
void push(char ch);
char pop();
char stack[max];
int top=-1;
void main()
{
char a[20],b[20],k[40],ch;
int i,l1,l2;
clrscr();
printf("\n Enter First String:-\n");
scanf("%s",a);
printf("\n Enter Second String:-\n");
scanf("%s",b);
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l2;i++)
{
push(b[i]); //push second string into stack
}
push(' ');
for(i=0;i<l1;i++)
{
push(a[i]); //push first string into stack
}
printf("\n After concatenation of two string:-\n");
i=0;
while(top!=-1)
{
ch=pop();
if(ch==' ')
{
k[i]='\0';
printf("%s",strrev(k));
i=0;
}
else
{
k[i]=ch;
i++;
}
}
k[i]='\0';
printf("%s",strrev(k));
getch();
}
void push(char ch)
{
if(top==max-1)
{
printf("\n Stack is full");
}
else
{
top++;
stack[top]=ch;
}
}
char pop()
{
char t;
if(top==-1)
{
printf("\n Stack is Empty");
}
else
{
t=stack[top];
top--;
return(t);
}
}
Monday, April 6, 2015
C program for binary search
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],n,i,k,mid,s,e,f=0;
clrscr();
printf("\n Enter how many number u want:-");
scanf("%d",&n);
printf("\n Please enter %d sorted numbers:-",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n numbers are:-");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\n\n Enter search key number:-\n");
scanf("%d",&k);
s=0;
e=n-1;
while(s<=e)
{
mid=(s+e)/2;
if(k==a[mid])
{
printf("\n %d number is found on %d position.",k,mid+1);
f=1;
break;
}
else
{
if(k>a[mid])
{
s=mid+1;
}
else
{
e=mid-1;
}
}
}
if(f==0)
{
printf("\n number is not found");
}
getch();
}
/* OUTPUT
Enter how many number u want:-5
Please enter 5 sorted numbers:-10 11 12 13 14
numbers are:- 10 11 12 13 14
Enter search key number:-
12
12 number is found on 3 position. */
#include<conio.h>
void main()
{
int a[20],n,i,k,mid,s,e,f=0;
clrscr();
printf("\n Enter how many number u want:-");
scanf("%d",&n);
printf("\n Please enter %d sorted numbers:-",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n numbers are:-");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\n\n Enter search key number:-\n");
scanf("%d",&k);
s=0;
e=n-1;
while(s<=e)
{
mid=(s+e)/2;
if(k==a[mid])
{
printf("\n %d number is found on %d position.",k,mid+1);
f=1;
break;
}
else
{
if(k>a[mid])
{
s=mid+1;
}
else
{
e=mid-1;
}
}
}
if(f==0)
{
printf("\n number is not found");
}
getch();
}
/* OUTPUT
Enter how many number u want:-5
Please enter 5 sorted numbers:-10 11 12 13 14
numbers are:- 10 11 12 13 14
Enter search key number:-
12
12 number is found on 3 position. */
C program for linear searching
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],n,i,k,f=0;
clrscr();
printf("\n Enter how many number u want:-");
scanf("%d",&n);
printf("\n Enter %d numbers:-",n);
for(i=0;i<n;i++)
{
scanf(" %d",&a[i]);
}
printf("\n numbers are:-\n");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\n Enter search key number:-");
scanf("%d",&k);
for(i=0;i<n;i++)
{
if(k==a[i])
{
printf("\n %d number is found on %d position.",k,i+1);
f=1;
break;
}
}
if(f==0)
{
printf("\n Number is not found");
}
getch();
}
/*
Enter how many number u want:-5
Enter 5 numbers:-4 6 8 9 14
numbers are:-
4 6 8 9 14
Enter search key number:-9
9 number is found on 4 position. */
#include<conio.h>
void main()
{
int a[10],n,i,k,f=0;
clrscr();
printf("\n Enter how many number u want:-");
scanf("%d",&n);
printf("\n Enter %d numbers:-",n);
for(i=0;i<n;i++)
{
scanf(" %d",&a[i]);
}
printf("\n numbers are:-\n");
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\n Enter search key number:-");
scanf("%d",&k);
for(i=0;i<n;i++)
{
if(k==a[i])
{
printf("\n %d number is found on %d position.",k,i+1);
f=1;
break;
}
}
if(f==0)
{
printf("\n Number is not found");
}
getch();
}
/*
Enter how many number u want:-5
Enter 5 numbers:-4 6 8 9 14
numbers are:-
4 6 8 9 14
Enter search key number:-9
9 number is found on 4 position. */
C program in data structure to make circular linked list
#include<stdio.h>
#include<conio.h>
#include<process.h>
void create();
void display();
void addbeg();
void addlast();
struct node
{
int info;
struct node *link;
}*start=NULL;
void main()
{
int n;
clrscr();
while(1)
{
printf("\n **menu**\n");
printf("\n 1. to create list \n 2. to display list");
printf("\n 3. to add node at beginning of linked list");
printf("\n 4. to add node at the last of linked list");
printf("\n 5. exit");
printf("\n Enter your choice:-");
scanf("%d",&n);
switch(n)
{
case 1 : create();
break;
case 2 : display();
break;
case 3 : addbeg();
break;
case 4 : addlast();
break;
case 5 : exit(0);
}
}
getch();
}
void create()
{
struct node *temp,*q;
int x;
temp=(struct node *)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
}
else
{
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start==NULL)
{
start=temp;
}
else
{
q=start;
while(q->link!=start)
{
q=q->link;
}
q->link=temp;
}
temp->link=start;
}
}
void display()
{
struct node *q;
printf("\n Circular linked list is:-\n\n");
q=start;
while(q->link!=start)
{
printf(" %d",q->info);
q=q->link;
}
printf(" %d",q->info);
}
void addbeg()
{
int x;
struct node *temp,*q;
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
}
else
{
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
q=start;
while(q->link!=start)
{
q=q->link;
}
temp->link=start;
start=temp;
q->link=start;
}
}
void addlast()
{
struct node *temp,*q;
int x;
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
}
else
{
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
q=start;
while(q->link!=start)
{
q=q->link;
}
q->link=temp;
temp->link=start;
}
}
#include<conio.h>
#include<process.h>
void create();
void display();
void addbeg();
void addlast();
struct node
{
int info;
struct node *link;
}*start=NULL;
void main()
{
int n;
clrscr();
while(1)
{
printf("\n **menu**\n");
printf("\n 1. to create list \n 2. to display list");
printf("\n 3. to add node at beginning of linked list");
printf("\n 4. to add node at the last of linked list");
printf("\n 5. exit");
printf("\n Enter your choice:-");
scanf("%d",&n);
switch(n)
{
case 1 : create();
break;
case 2 : display();
break;
case 3 : addbeg();
break;
case 4 : addlast();
break;
case 5 : exit(0);
}
}
getch();
}
void create()
{
struct node *temp,*q;
int x;
temp=(struct node *)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
}
else
{
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start==NULL)
{
start=temp;
}
else
{
q=start;
while(q->link!=start)
{
q=q->link;
}
q->link=temp;
}
temp->link=start;
}
}
void display()
{
struct node *q;
printf("\n Circular linked list is:-\n\n");
q=start;
while(q->link!=start)
{
printf(" %d",q->info);
q=q->link;
}
printf(" %d",q->info);
}
void addbeg()
{
int x;
struct node *temp,*q;
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
}
else
{
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
q=start;
while(q->link!=start)
{
q=q->link;
}
temp->link=start;
start=temp;
q->link=start;
}
}
void addlast()
{
struct node *temp,*q;
int x;
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
}
else
{
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
q=start;
while(q->link!=start)
{
q=q->link;
}
q->link=temp;
temp->link=start;
}
}
C program in data structure to find the intersection between two linked list
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<stdlib.h>
struct node
{
int info;
struct node *link;
}*start1=NULL,*start2=NULL;
void main()
{
struct node *temp,*q,*p;
int n,i,x,f=0;
clrscr();
printf("\n First linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start1==NULL)
{
start1=temp;
}
else
{
q=start1;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n first list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
start2=NULL;
printf("\n Second linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start2==NULL)
{
start2=temp;
}
else
{
q=start2;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n second list\n");
q=start2;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
printf("\n intersection of two list is:-\n");
q=start1;
while(q!=NULL)
{
p=start2;
while(p!=NULL)
{
if(q->info==p->info)
{
printf("\t%d",q->info);
}
p=p->link;
}
q=q->link;
}
getch();
}
/* OUTPUT
First linked list
Enter How many number:-5
Enter number:-1
Enter number:-2
Enter number:-3
Enter number:-4
Enter number:-5
first list
1 2 3 4 5
Second linked list
Enter How many number:-4
Enter number:-1
Enter number:-2
Enter number:-5
Enter number:-6
second list
1 2 5 6
intersection of two list is:-
1 2 5
*/
#include<conio.h>
#include<process.h>
#include<stdlib.h>
struct node
{
int info;
struct node *link;
}*start1=NULL,*start2=NULL;
void main()
{
struct node *temp,*q,*p;
int n,i,x,f=0;
clrscr();
printf("\n First linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start1==NULL)
{
start1=temp;
}
else
{
q=start1;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n first list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
start2=NULL;
printf("\n Second linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start2==NULL)
{
start2=temp;
}
else
{
q=start2;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n second list\n");
q=start2;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
printf("\n intersection of two list is:-\n");
q=start1;
while(q!=NULL)
{
p=start2;
while(p!=NULL)
{
if(q->info==p->info)
{
printf("\t%d",q->info);
}
p=p->link;
}
q=q->link;
}
getch();
}
/* OUTPUT
First linked list
Enter How many number:-5
Enter number:-1
Enter number:-2
Enter number:-3
Enter number:-4
Enter number:-5
first list
1 2 3 4 5
Second linked list
Enter How many number:-4
Enter number:-1
Enter number:-2
Enter number:-5
Enter number:-6
second list
1 2 5 6
intersection of two list is:-
1 2 5
*/
C program in data structure to reverse the singly linked list
/* Reverse the singly linked list */
#include<stdio.h>
#include<conio.h>
#include<process.h>
struct node
{
int info;
struct node *link;
}*start=NULL;
void main()
{
struct node *temp,*q,*p,*t;
int n,i,x;
clrscr();
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start==NULL)
{
start=temp;
}
else
{
q=start;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
t=NULL;
for(i=0;i<n;i++)
{
q=start;
while(q->link!=t)
{
q=q->link;
}
t=q;
printf("\n %d",q->info);
}
getch();
}
/* OUTPUT
Enter How many number:-5
Enter number:-1
Enter number:-2
Enter number:-3
Enter number:-4
Enter number:-5
5
4
3
2
1
#include<stdio.h>
#include<conio.h>
#include<process.h>
struct node
{
int info;
struct node *link;
}*start=NULL;
void main()
{
struct node *temp,*q,*p,*t;
int n,i,x;
clrscr();
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start==NULL)
{
start=temp;
}
else
{
q=start;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
t=NULL;
for(i=0;i<n;i++)
{
q=start;
while(q->link!=t)
{
q=q->link;
}
t=q;
printf("\n %d",q->info);
}
getch();
}
/* OUTPUT
Enter How many number:-5
Enter number:-1
Enter number:-2
Enter number:-3
Enter number:-4
Enter number:-5
5
4
3
2
1
C program in data structure for concatenate two linked list
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<string.h>
struct node
{
int info;
struct node *link;
}*start1=NULL,*start2;
void main()
{
struct node *temp,*q;
int n,i,x;
clrscr();
printf("\n First linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start1==NULL)
{
start1=temp;
}
else
{
q=start1;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n first list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
start2=NULL;
printf("\n Second linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start2==NULL)
{
start2=temp;
}
else
{
q=start2;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n second list\n");
q=start2;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
q=start1;
while(q->link!=NULL)
{
//concatenate two linked list
q=q->link;
}
q->link=start2;
printf("\n After concatenate linked list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
getch();
}
#include<conio.h>
#include<process.h>
#include<string.h>
struct node
{
int info;
struct node *link;
}*start1=NULL,*start2;
void main()
{
struct node *temp,*q;
int n,i,x;
clrscr();
printf("\n First linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start1==NULL)
{
start1=temp;
}
else
{
q=start1;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n first list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
start2=NULL;
printf("\n Second linked list");
printf("\n Enter How many number:-");
scanf("%d",&n);
for(i=0;i<n;i++)
{
temp=(struct node*)malloc(sizeof(struct node));
if(temp==NULL)
{
printf("\n Insufficient memory");
getch();
exit(0);
}
printf("\n Enter number:-");
scanf("%d",&x);
temp->info=x;
temp->link=NULL;
if(start2==NULL)
{
start2=temp;
}
else
{
q=start2;
while(q->link!=NULL)
{
q=q->link;
}
q->link=temp;
}
}
printf("\n second list\n");
q=start2;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
q=start1;
while(q->link!=NULL)
{
//concatenate two linked list
q=q->link;
}
q->link=start2;
printf("\n After concatenate linked list\n");
q=start1;
while(q!=NULL)
{
printf("\t%d",q->info);
q=q->link;
}
getch();
}
RDBMS example for project with different quiries
SQL> create table project
2 (pno number(5) primary key,
3 pname varchar2(20),
4 status varchar2(5)
5 check (status in('c','p','i')));
Table created.
SQL> insert into project values (&pno,'&pname','&status');
SQL> select * from project;
PNO PNAME STATU
---------- -------------------- -----
11 voice_recognition i
12 speech_recognition c
13 video_recognition i
14 steganography p
15 cryptography i
SQL> create table dept
2 (deptno number(5) primary key,
3 deptname varchar2(20),
4 HOD varchar2(20),
5 location varchar2(20));
Table created.
SQL> insert into dept values (&deptno,'&deptname','&HOD','&location');
SQL> select * from dept;
DEPTNO DEPTNAME HOD LOCATION
---------- -------------------- -------------------- --------------------
1 mathematics vijay pune
2 computer ranjit pune
3 chemical rahul nasik
4 civil ajay nagpur
5 IT santosh nanded
SQL> create table dep_pro
2 (deptno number(5) references dept,
3 pno number(5) references project,
4 primary key (deptno,pno));
Table created.
SQL> insert into dep_pro values (&deptno,&pno);
SQL> select * from dep_pro;
DEPTNO PNO
---------- ----------
1 11
2 12
3 13
4 14
5 15
Queries:-
1 Find HOD of computer Department located in ‘Pune’.
SQL> select HOD from dept
2 where deptname='computer' and location='pune';
HOD
--------------------
Ranjit
2 List all projects of mathematics department which are Incomplete.
SQL>select project.*
from dept,project
where dept.deptno=project.deptno and statu='i'
and deptname='mathmatics';
PNO PNAME STATU
---------- -------------------- -----
11 voice_recognition i
3 Display the Project details of Computer Department.
SQL>select project.*
from dept,project
where dept.deptno=project.deptno and deptname='Computer';
PNO PNAME
---------- --------------------
12 speech_recognition
4 List department wise project along with status.
SQL> select deptname,pname,status from project,dept,dep_pro
2 where project.pno=dep_pro.pno and
3 dep_pro.deptno=dept.deptno
4 group by deptname,pname,status;
DEPTNAME PNAME STATU
-------------------- -------------------- -----
IT cryptography i
chemical video_recognition i
civil steganography p
computer speech_recognition c
mathematics voice_recognition c
2 (pno number(5) primary key,
3 pname varchar2(20),
4 status varchar2(5)
5 check (status in('c','p','i')));
Table created.
SQL> insert into project values (&pno,'&pname','&status');
SQL> select * from project;
PNO PNAME STATU
---------- -------------------- -----
11 voice_recognition i
12 speech_recognition c
13 video_recognition i
14 steganography p
15 cryptography i
SQL> create table dept
2 (deptno number(5) primary key,
3 deptname varchar2(20),
4 HOD varchar2(20),
5 location varchar2(20));
Table created.
SQL> insert into dept values (&deptno,'&deptname','&HOD','&location');
SQL> select * from dept;
DEPTNO DEPTNAME HOD LOCATION
---------- -------------------- -------------------- --------------------
1 mathematics vijay pune
2 computer ranjit pune
3 chemical rahul nasik
4 civil ajay nagpur
5 IT santosh nanded
SQL> create table dep_pro
2 (deptno number(5) references dept,
3 pno number(5) references project,
4 primary key (deptno,pno));
Table created.
SQL> insert into dep_pro values (&deptno,&pno);
SQL> select * from dep_pro;
DEPTNO PNO
---------- ----------
1 11
2 12
3 13
4 14
5 15
Queries:-
1 Find HOD of computer Department located in ‘Pune’.
SQL> select HOD from dept
2 where deptname='computer' and location='pune';
HOD
--------------------
Ranjit
2 List all projects of mathematics department which are Incomplete.
SQL>select project.*
from dept,project
where dept.deptno=project.deptno and statu='i'
and deptname='mathmatics';
PNO PNAME STATU
---------- -------------------- -----
11 voice_recognition i
3 Display the Project details of Computer Department.
SQL>select project.*
from dept,project
where dept.deptno=project.deptno and deptname='Computer';
PNO PNAME
---------- --------------------
12 speech_recognition
4 List department wise project along with status.
SQL> select deptname,pname,status from project,dept,dep_pro
2 where project.pno=dep_pro.pno and
3 dep_pro.deptno=dept.deptno
4 group by deptname,pname,status;
DEPTNAME PNAME STATU
-------------------- -------------------- -----
IT cryptography i
chemical video_recognition i
civil steganography p
computer speech_recognition c
mathematics voice_recognition c
Subscribe to:
Posts (Atom)
Featured posts
Happy Independence Day August 15th
Here's a message for India's Independence Day (August 15th): "शुभ स्वतंत्रता दिवस! आजादी की 79वीं वर्षगांठ पर, आइए हम अपने देश...

Popular posts
-
A warehouse in the supply chain business plays a crucial role in storing and managing inventory. Here's a brief overview: Key Functions...