Remember
me?
RegisterForgot Your Password?

Category Archives: SY (BCA)

Program to create a binary tree and perform recursive and non-recursive traversals

C++ program to create binary tree and perform recursive and non-recursive traversals.

download :  SOURCE  CODE      OUTPUT

Description :

binary tree is a data structure in which each node has at most two child nodes called  as “left” and “right”. The tree has a header, which contains a link to a designated node (the root node). The root node has no parent.

Code :

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

typedef struct node
{
int data;
struct node *left;
struct node *right;
}node;

class tree
{
public:
node *root;

tree()
{
root=NULL;
}

C Program to check well parenthesis of an infix expression using stack

Program to read a parenthesized infix expression from user & check whether it is well parenthesized or not using static implementation of stack

download :SOURCE CODE

Description :

The following code uses stack operations like push,pop,init,isfull,isempty .User is

asked to enter an infix expression.Every character in the expression is compared

using a switch case to find whether every opening

bracket has a closed bracked associated woth it.This is called as parathesis check.

Code :

#include<stdio.h>
#include<conio.h>
#define MAX 100

‘C’ program to remove first node of the list and insert it at the end of the list.

download : Source Code

Description :The code for removing first node from the list and insert
it at the last

The code consists of three modules-

-create :It is used to create the linked list

-display :It displays the list

-remove:It takes the start node of the list a parameter.The start is stored in a temporary

Binary tree:Number of nodes,Degree of tree,Leaf nodes,Interior nodes

download : source code

Description :C program to display total number of nodes of binary tree,Degree,Number of leaf nodes,Display interior nodes .

The following code consist of five modules-

1.no of leaf nodes
2.degree of tree
3.leaf nodes
4.interior nodes
5.children of parent

C Program to read ‘n’ integers and store them in binary search tree structure. Display mirror image of tree.(using recursive function)

download :  Source Code

Description :C Program to display mirror image of binary tree using

inorder.

The code consists of three modules -

1)create-This function creates a binary tree

2)mirror-Its a recursive function

3)inorder-It is used to display the tree in a left->root->right fashion.

create mirror inorder

Code :

RDBMS

1.Consider the following Entities and their Relationships                           

Department (deptno, deptname,location)

Employee (empno, empname, salary, commission, designation)

 Relationship between Department and Employee is one-to-many.

 Constraints : Primary Key

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL Procedure to display details of a given employee.

 b)      Write a Cursor to display total salary (Salary + Commission) of all employees.

2.Consider the following Entities and their Relationships                           

            Customer (cno, cname, city)

            Account (ano, acc_type, balance)

   Relationship between Customer and Account is one to many

   Constraints:   Primary key,

                                    acc_type should not be null.

   Create a RDB in 3NF & write queries in Oracle 8i for following.

   a)      Create or Replace a PL/SQL function to return account balance of a given customer. 

   b)      Create or replace a trigger that restricts insertion or updation of account having balance less than 100.

3.Consider the following Entities and their Relationships                                            

Movie (mvno, mvname, releaseyear)

Actor (actno, actname)

Movie and Actor are related with many to many relationships with descriptive attribute rate of actor for movie.

 Constraints:   Primary Key.

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL Procedure to display details of all movies of actor ‘Amitabh’.

 b)      Write a cursor to display names of all movies which are released in year 2002.

4.Consider the following Entities and Relationships                        

            Book (bno, bname, pubname, price)

            Department (dno, dname)

   Relationship between Book and Department is many to one.

   Constraints:   Primary key,

                                    Price should be > 0

   Create a RDB in 3NF & write queries in Oracle 8i for following.

     a)      Create or Replace a PL/SQL function to return total expenditure on books of a given department.

     b)      Write a cursor to display details of all books brought for a ‘Computer’ department. 

5.Consider the following Entities and their Relationships                            

                       Book ( bno, bname, pubname, price)

                       Author (ano, aname)

 The relationship between Book and Author is many-to-many.

 Constraints : Primary Key,

                        aname and pubname should not be null.

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL Procedure to display details of all books written by ‘Kanetkar’.

 b)      Create or replace a Trigger that restricts insertion or updation of books having price less than 0.

6.Consider the following Entities and their Relationships                           

           Employee (eno, ename, city, deptname)

            Project (pno, pname, status)

Relationship between Employee and project is many to many with descriptive attribute number_of_days employee worked on that project.

Constraints:   Primary key,

            Status has to be C-Complete, P-Progressive, I-Incomplete

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL function to return total number of employees working on any project for more than 25 days. 

 b)      Write a cursor to display all employee names working on a project whose status is Incomplete. 

7.Consider the following Entities and their Relationships                           

             Customer (cno, cname, city)

            Account (ano, acc_type, balance)

  Relationship between Customer and Account is one to many

 Constraints:   Primary key,

                        Balance should be >100

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)    Write a cursor to add interest of 3 % to the balance of all accounts whose balance is greater than 10000.

8.Consider the following Entities and their Relationships                         

              Doctor (dno, dname, dcity)

              Hospital (hno, hname, hcity)

 The relation between Doctor and Hospital is many-to-many.

 Constraints : Primary Key,

dcity and hcity should not be null

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL Procedure to display details of all hospitals in ‘Pune’.

 b)      Write a cursor to list all hospitals and their doctor’s details.

9.Consider the following Entities and their Relationships                                                     

  Student (rollno, name, class, totalmarks)

  Teacher (tno, tname)

 The relation between Student and Teacher is many-to-many with subject as descriptive attribute.

 Constraints : Primary Key,

                        Class has to be FY, SY or TY.

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL Procedure to display details of all students of class ‘FY’.

 b)      Create or replace a Trigger that restricts insertion or updation of students having totalmarks less than 0.

10.Consider the following Entities and their Relationships                                       

             Employee (eno, ename, city, deptname)

            Project (pno, pname, status)

Relationship between Employee and project is many to many with descriptive attribute number_of_days employee worked on that project.

Constraints:   Primary key,

            Status has to be C-Complete, P-Progressive, I-Incomplete

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a trigger before update on status of project such that status of project once complete can not be changed. Display appropriate message. 

11.Consider the following Entities and their Relationships                         

             Department (deptno, deptname, location)

             Employee (empno, empname, salary, commission, designation)

 Relationship between Department and Employee is one-to-many.

 Constraints : Primary Key

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL Procedure to increase the salary of a given employee by 5% & display updated salary.

 b)      Write a Cursor to display details of all Employees of all Departments.

12.Consider the following Entities and their Relationships                           

           Customer (cno, cname, city)

           Loan (lno, loan_amt, no_of_years)

   Relationship between Customer and Loan is one to many

   Constraints:   Primary key,

                                    loan_amt should be > 0.

   Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL function to find total loan amount from ‘Mumbai’ city. 

 b)      Write a cursor to display details of all customers who have taken loan for more than 3 years.

13.Consider the following Entities and their Relationships                                           

            Movie (mvno, mvname, releaseyear)

            Actor (actno, actname)

 Movie and Actor are related with many to many relationships with descriptive attribute rate of actor for movie.

 Constraints:   Primary Key.

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace PL/SQL function to return total number of movies of ‘Aishwarya’.

 b)      Create or replace a Trigger that restricts insertion or updation of movies released before year 2005.

14.Consider the following Entities and their Relationships                                            

            Book (bno, bname, pubname, price)

            Department (dno, dname)

Relationship between Book and Department is many to one   

Constraints:   Primary key,

                                    pubname should not be null  

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL function to return total number of books purchased by a given department.

 b)      Create or Replace a trigger that restricts insertion or updation of book having price less than 0.

15.Consider the following Entities and their Relationships                            

            Book ( bno, bname, pubname)

            Author (ano, aname)

 The relation between Book and Author is many-to-many.

 Constraints : Primary Key,

                        aname and pubname should not be null.

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Write a cursor to display list of authors and their books details.

 b)      Create or Replace PL/SQL function to count the total number of books of ‘BPB’ Publication.

16.Consider the following Entities and their Relationships                            

            Customer (cno, cname, city)

            Account (ano, acc_type, balance)

  Relationship between Customer and Account is one to many

 Constraints:   Primary key,

                                    acc_type should not be null.

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Write a cursor to display details of all customers from ‘Pune’ city having A/C balance between 20000 and 40000.

 b)      Create or Replace a PL/SQL function to return total number of customers having ‘Saving’ account.

17.Consider the following Entities and their Relationships                            

                Doctor (dno, dname, dcity)

                Hospital (hno, hname, hcity)

 The relation between Doctor and Hospital is many-to-many.

 Constraints : Primary Key,dcity and hcity should not be null

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace PL/SQL function to count the total number of doctors who are visiting to ‘KEM’ hospital.

 b)      Write a cursor to list all doctors and hospitals visited by them. 

 18.Consider the following Entities and their Relationships                            

           Employee (eno, ename, city, deptname)

            Project (pno, pname, status)

Relationship between Employee and project is many to many with descriptive attribute number_of_days employee worked on that project.

Constraints:   Primary key,Status has to be C-Complete, P-Progressive, I-Incomplete

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace PL/SQL procedure to increment number_of_days by 2 of all employees working on project having status progressive.

 b)      Create or Replace a trigger that restricts insertion or updation of table such that number_of_days should not be less than zero. 

19.Consider the following Entities and their Relationships                                                        

Student (rollno, name, class, totalmarks)

Teacher (tno, tname)

The relation between Student and Teacher is many-to-many with subject as descriptive attribute.

Constraints : Primary Key,

                        Class has to be FY, SY or TY.

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL Procedure to display details of all teachers who are teaching subject ‘Data Structure’.

 b)      Create or replace a Trigger that restricts insertion or updation of students having totalmarks greater than 500.

20.Consider the following Entities and their Relationships                                                      

            Customer (cno, cname, city)

            Loan (lno, loanamt, no_of_years)

Relationship between Customer and Loan is one to many

Constraints:   Primary key,loanamt should be > 0.

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL procedure to display customer details who have taken maximum loan from ‘Pune’ city. 

 b)      Create or Replace a trigger which will execute when loan amount is updated. Do not allow to update. Display appropriate message. 

21.Consider the following Entities and their Relationships                            

           Department (deptno, deptname,location)

           Employee (empno, empname, salary, commission, designation)

 Relationship between Department and Employee is one-to-many.

 Constraints : Primary Key,

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace PL/SQL function to return employee name having minimum salary in Computer Department

 b)      Create or replace a Trigger for an Employee table that restricts insertion or updation or deletion on Sunday.

22.Consider the following Entities and their Relationships                            

           Book (bno, bname, pubname, price)

           Department (dno, dname)

Relationship between Book and Department is many to one   

Constraints:   Primary key,Price should be > 0

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL procedure to increase the price of all books by 5 % for given pubname and display updated book details. 

 b)      Write a cursor to display all department’s name having more than 2 books of ‘BPB’ publication.

23.Consider the following Entities and their Relationships                                          

                 Movie (mvno, mvname, releaseyear)

                 Actor (actno, actname)

Movie and Actor are related with many to many relationships with descriptive attribute rate of actor for movie.

Constraints:   Primary Key.

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL Procedure to display details of all actors acted in movie ‘Race’.

 b)      Write a cursor to display the list of actors and their movies for which their rate is greater than 20 Lakhs.

24.Consider the following Entities and their Relationships                                           

            Customer (cno, cname, city)

            Account (ano, acc_type, balance)

Relationship between Customer and Account is one to many

Constraints:   Primary key,acc_type should not be null.

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL procedure that will accept any two account number and withdrawal amount as input parameter to transfer withdrawal amount from first account to second account.

 b)      Write a cursor to list all customers & their account details.

25.Consider the following Entities and their Relationships                           

                    Student (rollno, name, class, totalmarks)

                   Teacher (tno, tname)

The relation between Student and Teacher is many-to-many with subject as descriptive attribute.

 Constraints : Primary Key,Class has to be FY, SY or TY.

 Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace PL/SQL function to return student name that has scored maximum marks in ‘TY’.

 b)      Create or Replace PL/SQL function to return total number of teachers who are teaching subject ‘Accounts’.

26.Consider the following Entities and their Relationships                          

            Employee (eno, ename, city, deptname)

            Project (pno, pname, status)

Relationship between Employee and project is many to many with descriptive attribute number_of_days employee worked on that project.

Constraints:   Primary key,Status has to be C-Complete, P-Progressive, I-Incomplete

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL procedure to find number of employees of a given department working on project having status ‘Incomplete’.

 b)      Write a cursor to display details of all projects along with status and number_of_days on which a given employee works. 

27.Consider the following Entities and their Relationships                           

 Department (deptno, deptname,location)

Employee (empno, empname, salary, commission, designation)

Relationship between Department and Employee is many-to-one.

Constraints : Primary Key,

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace PL/SQL function to return total number of employees working in ‘Computer’ Department

 b)      Create or replace a Trigger for updation of an Employee table that restricts new salary should not less than old salary.

28.Consider the following Entities and their Relationships                           

            Politician (pno, pname, description)

            Party (partycode, partyname)

Relationship between Politician and Party is many to one

Constraints:   Primary key,partyname should not be null.

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)      Create or Replace a PL/SQL function to return total number of politician of a given party.

 b)  Write a cursor to display details of all politicians of ‘BJP’ party. 

29.Consider the following Entities and their Relationships                                          

Movie (mvno, mvname, releaseyear)

Actor (actno, actname)

Movie and Actor are related with many to many relationships with descriptive attribute rate of actor for movie.

Constraints:   Primary Key.

Create a RDB in 3NF & write queries in Oracle 8i for following.

 a)   Create or replace a Trigger that restricts insertion or updation of movies released before year 2000.

 b)   Create or Replace PL/SQL function to return total number of actors acted in movie ‘Gajani’

30.Consider the following Entities and their Relationships                                           

            Book (bno, bname, pubname, price)

            Department (dno, dname)

Relationship between Book and Department is many to one   

Constraints:   Primary key,Price should be > 0

Create a RDB in 3NF & write queries in Oracle 8i for following.

a)      Create or Replace a PL/SQL procedure to display name of department spending maximum amount on books. 

 b)     Write a cursor to display department wise expenditure on books.

 

 

 

 

 

 

 

 

 

 

 

Static implementation of circular queue for integers

A menu driven program in ‘C’ for static implementation of Circular Queue for integers.  The menu includes

-          Insert

-          Delete

-          Display

-          Exit

DOWNLOAD  SOURCE CODE  OUTPUT

CODE:
#include<stdio.h>
#include<malloc.h>
struct node
{
int info;
struct node *next;
} *front, *rear;
void enqueue(int elt);
int dequeue();
void display();
void main()
{
int ch;
int elt;
clrscr();
rear = NULL;
front = NULL;
do
{
printf(“\n************ Menu ***************”);
printf(“\nEnter:\n1->Insert\n2->Delete\n3->Display\n4->Exit\n”);
printf(“Enter your choice :: “);
scanf(“%d”, &ch);
switch (ch)
{
case 1:
printf(“Enter the integer no\n “);
scanf(“%d”,&elt);
enqueue(elt);
break;
case 2:
elt = dequeue();
printf(“The deleted element = %d\n”, elt);
break;
case 3:
display();
break;
default:
printf(“~~~Exit~~~”);
getch();
exit(0);
break;
}
}while(ch!=4);
}
void enqueue(int elt)
{
struct node *p;
p = (struct node*)malloc(sizeof(struct node));
p->info = elt;
p->next = NULL;
if (rear == NULL || front == NULL)
front = p;
else
rear->next = p;
rear = p;
}
int dequeue()
{
struct node *p;
int elt;
if (front == NULL || rear == NULL)
{
printf(“\nUnder Flow”);
getch();
exit(0);
}
else
{
p = front;
elt = p->info;
front = front->next;
free(p);
}
return (elt);
}
void display()
{
struct node *t;
t = front;
while (front == NULL || rear == NULL)
{
printf(“\nQueue is empty”);
getch();
exit(0);
}
while (t != NULL)
{
printf(“->%d”,t->info);
t = t->next;
}
}

OUTPUT:
************ Menu ***************
Enter:
1->Insert
2->Delete
3->Display
4->Exit
Enter your choice :: 1
Enter the integer no
2

************ Menu ***************
Enter:
1->Insert
2->Delete
3->Display
4->Exit
Enter your choice :: 1
Enter the integer no
5

************ Menu ***************
Enter:
1->Insert
2->Delete
3->Display
4->Exit
Enter your choice :: 1
Enter the integer no
7

************ Menu ***************
Enter:
1->Insert
2->Delete
3->Display
4->Exit
Enter your choice :: 3
->2->5->7
************ Menu ***************
Enter:
1->Insert
2->Delete
3->Display
4->Exit
Enter your choice :: 2
The deleted element = 2

************ Menu ***************
Enter:
1->Insert
2->Delete
3->Display
4->Exit
Enter your choice ::3
->5->7
************ Menu ***************
Enter:
1->Insert
2->Delete
3->Display
4->Exit
Enter your choice ::4

Palindrome of string using static implementation of stack

A ‘C’ program to read a string and check whether string is palindrome or not. (using static implementation of stack)

DOWNLOAD  SOURCE CODE  OUTPUT

CODE:

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define SIZE 10

typedef struct
{
int items[SIZE];
int top;

}STACK;
void push();
int pop();
void display();
int isoverflow();
int isempty();

int main()
{
STACK s;
char str[100];
int i, flag;

s.top = -1;

printf(“\nEnter a string: “);
gets(str);

for(i=0;str[i]!=’\0′; i++)
push(&s, str[i]);

flag = 1;
for(i=0;str[i]!=’\0′;i++)
{
if(str[i] != pop(&s))
{
flag = 0;
break;
}
}

if(flag == 1)
printf(“\nEntered string is palindrome\n”);
else
printf(“\nEntered string is not a palindrome\n”);
getch();

}

void push(STACK *p, int element)
{
if(isoverflow(p->top))
{
printf(“\nStack is overflow”);
}
else
{
(p->top)++;
p->items[p->top] = element;
}
}

int pop(STACK *p)
{
if(isempty(p->top))
{
printf(“\nStack is underflow”);
}
else
{
return (p->items[(p->top)--]);
}
}

void display(STACK s)
{
int i;
if(isempty(s.top))
{
printf(“\nStack is empty”);
}
else
{
for(i=s.top; i>=0; i–)
{
printf(“\n%d”, s.items[i]);
}
}
}

//Function to check stack overflow condition
int isoverflow(int top)
{
if(top == SIZE – 1)
return (1);
else
return (0);
}

//Function to check stack empty condition
int isempty(int top)
{
if(top == -1)
return (1);
else
return (0);
}

OUTPUT:
Enter a string: nitin

Entered string is palindrome

Enter a string: mad

Entered string is not a palindrome