Computer Project 1KIDDIES

download Computer Project 1KIDDIES

of 57

Transcript of Computer Project 1KIDDIES

  • 8/11/2019 Computer Project 1KIDDIES

    1/57

    ertificate

    Student Name.................................................................

    Std.........................................Roll No.............................

    This is to certify that activity written in the project

    have been performed by the student satisfactorily.

    Signature

    School Stamp Dated..................

  • 8/11/2019 Computer Project 1KIDDIES

    2/57

    AKNOWLEDGEMENT

    I want to express my sincere gratitude towards my school andrespective teachers who have helped me in completing this

    project. I am extremely grateful to them for extending their

    guidance and cooperation throughout this project which in turn

    has resulted in a great strength to carve my creative ideas. I

    remain grateful to all, my respected teachers for their all timesupport. I am also thankful for the supporting staff of the

    school, who guided me for this project from time to time.

  • 8/11/2019 Computer Project 1KIDDIES

    3/57

    INDEX

    S No. PROGRAMMES PAGE NO REMARKS

    1. Program to Calculate Interest Amount using Function

    Overloading

    2.

    Circular Queue3. Binary Search

    4. Bubble Sort

    5. Insertion Sort

    6. Linear Search

    7. Merge Sort-I

    8. Merge Sort-II

    9. Merge Sort-III

    10. Product of Two Matrices

    11.

    Selection Sort12. Sum of Two Matrices

    13. Deleting an Element from Array using Location

    14. Inserting an Element into the Array at any Location

    15. Transpose of a Matrix

    16. Stack Program by Dynamic Memory Allocation

    17. Stack through Arrays

    18. Queue Program by Dynamic Memory Allocation

    19. Queue Implementation through Arrays

    20.

    SQL related Questions for tables Product and Client21. SQL related Questions for tables Consignor and

    Consignee

    22. SQL related Questions for tables Stock and Dealer

    23. SQL related Questions for tables Furniture and

    Arrivals

    24. Program on a Structure named Product

    25. Program on a Class named Book

    26. Program on a Class named Student

  • 8/11/2019 Computer Project 1KIDDIES

    4/57

    CALCULATE INTEREST AMOUNT USING FUNCTION OVERLOADING

    #include#include

    void amount(float princ,float rate,int time)

    {cout

  • 8/11/2019 Computer Project 1KIDDIES

    5/57

  • 8/11/2019 Computer Project 1KIDDIES

    6/57

    CIRCULAR QUEUE

    #include#include

    const int size=5;

    void insert(int[],int);void disp(int[],int,int);

    void del(int[]);int cqueue[size], front=-1, rear=-1;void main()

    {

    int item,ch;

    while(ch!=4){

    clrscr();

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    7/57

    return;}

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

    else

    if(rear==size-1)rear=0;

    elserear++;

    cqueue[rear]=ele;

    }

    void disp(int cqueue[],int front,int rear){

    int i=0;

    if(front==-1)

    {cout

  • 8/11/2019 Computer Project 1KIDDIES

    8/57

    front=rear=-1;else

    {if(front==size-1)

    front=0;

    elsefront++;

    }}

    OUTPUT: CIRCULAR QUEUE

  • 8/11/2019 Computer Project 1KIDDIES

    9/57

    BINARY SEARCH

    #include#include

    int bsearch(int a[],int n,int n1);

    void main(){

    int a[20],i,n,item,pos;clrscr();coutn;

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    10/57

    OUTPUT: BINARY SEARCH

  • 8/11/2019 Computer Project 1KIDDIES

    11/57

    BUBBLE SORT

    #include

    #includevoid bubble( int a[], int n);

    void main()

    {

    int a[30],i,n;clrscr();

    coutn;

    for(i=0;i

  • 8/11/2019 Computer Project 1KIDDIES

    12/57

    OUTPUT: BUBBLE SORT

  • 8/11/2019 Computer Project 1KIDDIES

    13/57

    INSERTION SORT

    #include

    #includevoid insertion(int [],int);

    void main()

    {

    int a[30],i,n;clrscr();

    coutn;

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    14/57

    OUTPUT: INSERTION SORT

  • 8/11/2019 Computer Project 1KIDDIES

    15/57

    LINEAR SEARCH

    #include#include

    int lsearch(int a[],int n,int n1);

    void main()

    {

    int a[30],i,n,n1,pos;clrscr();

    coutn;

    for(i=0;i

  • 8/11/2019 Computer Project 1KIDDIES

    16/57

    OUTPUT: LINEAR SEARCH

  • 8/11/2019 Computer Project 1KIDDIES

    17/57

    MERGE SORT

    CASE 1:#include

    #include

    void merge(int [],int [],int [],int,int);

    void main()

    {int a1[30],a2[30],a3[60],i,j,n,m;

    clrscr();coutn;

    coutm;

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    18/57

    p3++;}

    }/* the above loop will be terminated only when

    one of the array is fully traversed */

    /* to copy the rest of the array of a1 if it is left*/while(p1

  • 8/11/2019 Computer Project 1KIDDIES

    19/57

    MERGE SORT

    CASE 2:#include

    #include

    void merge(int [],int [],int [],int,int);

    void main()

    {int a1[30],a2[30],a3[60],i,j,n,m;

    clrscr();coutn;

    coutm;

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    20/57

    p3++;}

    }/* the above loop will be terminated only when

    one of the array is fully traversed */

    /* to copy the rest of the array of a1 if it is left*/while(p1>=0)

    {a3[p3]=a1[p1];p1=p1-1;

    p3++;

    }/* to copy the rest of the array of a2 if it is left*/

    while(p2>=0)

    {

    a3[p3]=a2[p2];p2=p2-1;

    p3++;

    }}

    OUTPUT: MERGE SORT

    CASE 2:

  • 8/11/2019 Computer Project 1KIDDIES

    21/57

    MERGE SORT

    CASE 3:#include

    #include

    void merge(int [],int [],int [],int,int);void main()

    {int a1[30],a2[30],a3[60],i,j,n,m;clrscr();

    coutn;

    coutm;

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    22/57

    p3++;}

    }while(p1=0)

    {

    a3[p3]=a2[p2];p2=p2-1;

    p3++;

    }

    }

    OUTPUT: MERGE SORT

    CASE 3:

  • 8/11/2019 Computer Project 1KIDDIES

    23/57

    PRODUCT OF TWO MATRICES

    #include#include

    void main()

    {int a[10][10],b[10][10],c[10][10],r1,c1,r2,c2,i,j,k;

    clrscr();coutr1>>c1;

    coutr2>>c2;

    //conditionif(c1==r2)

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    24/57

    }//display 2nd matrix

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    25/57

    SELECTION SORT

    #include#include

    void selection(int [],int);

    void main(){

    int a[30],i,n;clrscr();coutn;

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    26/57

    OUTPUT: SELECTION SORT

  • 8/11/2019 Computer Project 1KIDDIES

    27/57

    SUM OF TWO MATRICES

    #include

    #includevoid main()

    {

    int a[10][10],b[10][10],c[10][10],r1,c1,r2,c2,i,j;

    clrscr();coutr1>>c1;coutr2>>c2;

    //condition

    if(r1==r2 && c1==c2)cout

  • 8/11/2019 Computer Project 1KIDDIES

    28/57

    }//display 2nd matrix

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    29/57

    DELETING AN ELEMENT FROM THE ARRAY USING LOCATION

    #include#include

    #include

    void Delete(int a[],int n,int loc);void main()

    {int a[50],i,n,loc;clrscr();

    coutn;

    for(i=0;in-1 || loc

  • 8/11/2019 Computer Project 1KIDDIES

    30/57

    OUTPUT:DELETING AN ELEMENT FROM ARRAY

  • 8/11/2019 Computer Project 1KIDDIES

    31/57

    INSERTING AN ELEMENT INTO THE ARRAY AT ANY LOCATION

    #include

    #include#include

    void insert(int a[],int n,int loc,int num);

    void main()

    {int a[50];

    int i,n,loc,num;clrscr();

    coutn;

    for(i=0;in || loc

  • 8/11/2019 Computer Project 1KIDDIES

    32/57

    OUTPUT: INSERTING AN ELEMENT IN AN ARRAY

  • 8/11/2019 Computer Project 1KIDDIES

    33/57

    TRANSPOSE OF A MATRIX

    #include#include

    void main()

    {int a[10][10],r,c,i,j,s=0;

    clrscr();coutr>>c;

    //input

    for(i=0;i

  • 8/11/2019 Computer Project 1KIDDIES

    34/57

    OUT PUT TRANSPOSE OF A MATRIX

  • 8/11/2019 Computer Project 1KIDDIES

    35/57

    STACK PROGRAM BY DYNAMIC MEMORY ALLOCATION

    #include#includestruct node

    {int data;

    node*link;};node*p=NULL;

    void push()

    {

    node*temp;int num;

    coutnum;

    temp=new node;//1if(temp==NULL)

    {cout

  • 8/11/2019 Computer Project 1KIDDIES

    36/57

    void count(){

    int c=0;node*q;

    q=p;

    while(q!=NULL){

    c++;q=q->link;

    }

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    37/57

    OUTPUT: DYNAMIC STATIC

  • 8/11/2019 Computer Project 1KIDDIES

    38/57

    STACK THROUGH ARRAYS

    #include#include

    #include

    int stack[50], top =-1, size;void push()

    {int val;coutval;

    if(top

  • 8/11/2019 Computer Project 1KIDDIES

    39/57

    clrscr();cout

  • 8/11/2019 Computer Project 1KIDDIES

    40/57

    OUTPUT: STACK THROUGH ARRAYS

  • 8/11/2019 Computer Project 1KIDDIES

    41/57

    QUEUE PROGRAM BY DYNAMIC MEMORY ALLOCATION

    #include#include

    struct node

    {int data;

    node * link;};node*front= NULL, *rear =NULL;

    void add()

    {

    node *temp;int num;

    coutnum;

    temp= new node;//1if(temp==NULL)

    {cout

  • 8/11/2019 Computer Project 1KIDDIES

    42/57

    cout

  • 8/11/2019 Computer Project 1KIDDIES

    43/57

    OUTPUT: DYNAMIC QUEUE

  • 8/11/2019 Computer Project 1KIDDIES

    44/57

    QUEUE IMPLEMENTATION THROUGH ARRAYS

    #include#include

    int queue[30];

    int front=-1, rear=-1, size;void add()

    {int val;coutval;

    if(front==-1)

    {front = 0;

    rear = 0;

    }

    elseif(rear

  • 8/11/2019 Computer Project 1KIDDIES

    45/57

    for(i=front;i

  • 8/11/2019 Computer Project 1KIDDIES

    46/57

    OUTPUT: QUEUE IMPLEMENTATION THROUGH ARRAYS

  • 8/11/2019 Computer Project 1KIDDIES

    47/57

    Consider the following tables Product and Client. Write SQL commands for the

    following statement (i) to (iv) and give outputs for SQL queries (v) to (viii).

    Table: Product Table: Client

    C_ID ClientName City P_ID

    01 Cosmetic Shop Delhi FW05

    06 Total Health Mumbai BS0112 Live Life Delhi SH06

    15 Pretty Woman Delhi FW12

    16 Dreams Bangalore TP01

    (i) To display the details of those Clients whose City is Delhi.

    Ans. SELECT * FROM Client

    WHERE City = Delhi;

    (ii) To display the details of Products whose Price is in the range of 50 to 100 (Both values

    included).

    Ans. SELECT * FROM Product

    WHERE Price BETWEEN 50 to 100;

    (iii) To display the ClientName,City from table Client, and ProductName and Price from table

    Product with their corresponding matching P_ID.

    Ans. SELECT ClientName, City, ProductName, Price FROM Client, Product WHERE

    Client.P_ID=Product.P_ID;

    (iv) To increase the Price of All Products by 10.

    Ans. UPDATE ProductSET Price = Price + 10;

    (v) SELECT DISTINCT City FROM Client;

    Ans. DelhiMumbai

    Bangalore

    (vi) SELECT Manufacturer, MAX(Price), MIN(Price), Count(*)

    FROM Product GROUP BY Manufacturer;

    Ans. LAK 40 40 1ABC 55 45 2

    XYZ 120 95 2

    (vii) SELECT ClientName, ProductName

    FROM Product, Client

    WHERE Client.P_ID=Product.P_ID;

    Ans. Cosmetic Shop Face Wash

    Total Health Bath Soap

    P_ID ProductName Manufacturer Price

    TP01 Talcum Powder LAK 40

    FW05 Face Wash ABC 45BS01 Bath Soap ABC 55

    SH06 Shampoo XYZ 120

    FW12 Face Wash XYZ 95

  • 8/11/2019 Computer Project 1KIDDIES

    48/57

  • 8/11/2019 Computer Project 1KIDDIES

    49/57

  • 8/11/2019 Computer Project 1KIDDIES

    50/57

    Ans. R Singhal Rahul Kishore

    Amit Kumar S Mittal

    (vii) SELECT CneeName, CneeAddress FROM Consignee

    WHERE CneeCity NOT IN (Mumbai, Kolkalta);

    Ans. P Dhingra 16/J, Moore Enclave

    B P Jain 13, Block D, Avihar

    (viii) SELECT CneeID, CneeName FROM Consignee

    WHERE CnorID = MU15 OR CnorID = ND01;

    Ans. MU05 Rahul Kishore

    KO19 A P Roy

  • 8/11/2019 Computer Project 1KIDDIES

    51/57

  • 8/11/2019 Computer Project 1KIDDIES

    52/57

    (a2) Give the output of the following SQL queries:

    (i) SELECT COUNT(DISTINCT Dcode)

    FROM Stock;

    Ans. 3

    (ii) SELECT Qty*UnitPrice FROM Stock

    WHERE ItemNo = 5006;

    Ans. 4400

    (iii) SELECT Item, Dname FROM Stock S, Dealers D

    WHERE S.DCODE = D.Dcode AND ItemNO = 5004;

    Ans. Eraser Big Clear Deals

    (iv) SELECT MIN(StockDate) FROM Stock;

    Ans. 01-Jan-09

  • 8/11/2019 Computer Project 1KIDDIES

    53/57

    Consider the following tables Furniture and Arrival. Write SQL commands for the statements (a) to

    (f) and give outputs for (g).

    Table: Furniture

    No. Itemname Type Dateofstock Price Discount

    1 White Lotus Double Bed 23/02/02 30000 25

    2 Pink Feather Baby Cot 20/01/02 7000 203 Dolphin Baby Cot 19/02/02 9500 20

    4 Decent Office Table 01/01/02 25000 30

    5 Comfort Zone Double Bed 12/01/02 25000 25

    6 Donald Baby Cot 24/02/02 6500 15

    7 Royal Finish Office Table 20/02/02 18000 30

    8 Royal Tiger Sofa 22/02/02 31000 30

    9 Econo Sitting Sofa 13/12/01 9500 25

    10 Eating Paradise Dining Table 19/02/02 11500 25

    Table: Arrivals

    No. Itemname Type Dateofstock Price Discount

    11 Wood Comfort Double Bed 23/03/03 25000 25

    12 Old Fox Sofa 20/02/03 17000 20

    13 Micky Baby Cot 21/02/03 7500 15

    (a) To show all information about the Baby Cots from the Furniture table.

    Ans. SELECT *FROM Furniture

    WHERE TYPE = BabyCot;

    (b) To list the Itemname which are priced at more than 15000 from the Furniture table.

    Ans. SELECT Itemname

    FROM Furniture

    WHERE Price > 15000;

    (c) To list Itemname and Type of those items, in which Dateofstock is before 22/01/02 from the

    Furniture table in descending order of Itemname.

    Ans. SELECT Itemname, Type

    FROM Furniture

    WHERE Dateofstock < {22/01/02} ORDER BY Itemname;

    (d) To display Itemname and Dateofstock of those items, in which the Discount percentage is more

    the 25 from Furniture table.

  • 8/11/2019 Computer Project 1KIDDIES

    54/57

  • 8/11/2019 Computer Project 1KIDDIES

    55/57

    Declare structure named product with attributes as pno, pname, price, quantity and

    cost. Take input for details of 10 product and display the details along with cost.

    #include

    #include

    struct product

    {

    int pno;

    char pname[20];

    float price, qty, cost;

    }

    p[10];

    void main()

    {

    int i;

    clrscr();

    for(i=0;i>p[i].pname>>p[i].price>>p[i].qty;

    }

    for(i=0;i

  • 8/11/2019 Computer Project 1KIDDIES

    56/57

    Define a class named BOOK.

    Private Members

    bcode, noc integer type,

    title char size 15,

    price, cost float type,

    cal_cost() function to calculate cost (cost=price*qty)

    Public Members

    input() function to take input for the value of bcode,title,noc and price. output()

    funtion to call the function cal_cost to calculate total cost and display it.

    #include

    #includeclass BOOK

    {

    int bcode,noc;char title[20];

    float price, cost;

    void cal_cost(){

    cost = price * qty;

    }

    public:void input();

    void output();}void BOOK :: input()

    {

    coutbcode>>title>>price>>noc;

    }

    void BOOK :: output()

    {

    cal_cost();cout

  • 8/11/2019 Computer Project 1KIDDIES

    57/57

    Define a class named STUDENT

    Private member :- roll integer type,

    name char type size 20,

    m1,m2,m3,total,per float type,

    cal() to calculate total and percentage.

    Public Member :-

    input() to take input for roll name m1,m2,m3.

    display() to invoke the function cal() and display total and percentage.#include#include

    class STUDENT

    {int roll;

    char name[20];

    float m1, m2, m3, total, per;

    void cal(){

    total = m1+m2+m3;

    per = total/3;}

    public:

    void input();

    void display();

    };void STUDENT :: input()

    {coutroll>>name>>m1>>m2>m3;

    }void STUDENT :: display()

    {

    cal();

    cout