Thursday, July 26, 2012

Computerized Billing System Computer project


This computer project is useful for every one but was developed to solve the Project requirement of class –12 computer science student of CBSE school.

This project fullfil all the requirement of a class 12 computer project mainly : Classes, file handling and data structure. 

The project use standard C++ library functions defined in standard header file along with some non standard header file, though fully supported by Turbo C++ but not a part of syllabus.

NOTE: This is a complete CPP project, Just copy the below code in any NOTPAD and save it with CPP extension. Compile it and run.

If you still have any problem using this project, Just drop your message and i will try to solve the problem as soon as possible.

//----------------------------------------------------------------------------
//  Header Files Included
//----------------------------------------------------------------------------
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<fstream.h>
#include<ctype.h>
#include<graphics.h>
#include<conio.h>
//Function prototype declaration
void products_enter();
void members_enter();
void readp();
void readm();
void billing();
void sales();
void modifyp();
void modifym();
void instructions();
//----------------------------------------------------------------------------
// Function for GRAPHICS slide (cover page)
//----------------------------------------------------------------------------
int gmode,gdriver,r;
//----------------------------------------------------------------------------
// Structure for the products' records
//----------------------------------------------------------------------------

struct products_record
{
    float rate;
    int stock;
    int no;
    char name[20];
}; //end of structure
//Global variable
products_record ob1,ob2;  //declaring objects of the structure
fstream pro1,pro2;  //declaring a file stream
//----------------------------------------------------------------------------
// Structure for members' records
//----------------------------------------------------------------------------

struct members_record
{
    int no;
    char name[20];
    char add[50];
    long int tel;
    long int card;
    float amt ;
}; //end of structure
members_record m1,m2;  //creating objects
fstream mem1,mem2;     //declaring streams;

//----------------------------------------------------------------------------
//structure for store opertaions
//----------------------------------------------------------------------------

struct tables
{
    int no;
    int qty;
    char name[20];
    float rate;
    float total;
};

tables n1,n2;
int i=0;
float discount=0.0;

//Welcome screen of computerized billing system
void welcome()
{
    gdriver=DETECT;       //request auto detection
    initgraph(&gdriver,&gmode,"c:\\turboc3\\bgi");  //initialising graph
    /* read result of initialization */
    int errorcode = graphresult();
    if (errorcode != grOk)  /* an error occurred */
    {
        printf("Graphics error: %s\n", grapherrormsg(errorcode));
        printf("Press any key to halt:");
        getch();
        return;
    }
    setbkcolor(7);
    setcolor(15);
    settextstyle(SANS_SERIF_FONT,HORIZ_DIR,5);
    settextstyle(7,HORIZ_DIR,7);
    moveto(60,100);
    outtext("COMPUTERISED");
    moveto(160,210);
    outtext("BILLING ");
    moveto(160,320);
    outtext("SYSTEM");
    delay(1000);
    setcolor(7);
    int i=0;
    while(i<=2*getmaxx()-460)
    {
        line(0,i,i,0);
        i++;
        delay(15);
    }
    setcolor(RED);
    sound(1450);
    delay(20);
    sound(600);
    for (r=150;r<230;r+=15)
    {
        circle (315,239,r);
        sound(350+2*r);
        delay(19);
        sound(1250);
    }
    settextstyle(8,HORIZ_DIR,1);
    setcolor(LIGHTGREEN);
    sound(500);
    delay(5);
    moveto(245,160);
    outtext("Copyright (C)");
    sound(400);
    delay(23);
    moveto(185,180);
    sound(350);
    delay(50);
    sound(100);
    outtext("Reeta Sahoo");
    moveto(240,200);
    sound(250);
    delay(40);
    outtext("20006-2007 ");
    moveto(210,220);
    outtext("All Rights Reserved");
    sound(400);
    moveto(185,240);
    outtext("Code by: Reeta Sahoo");
    sound(450);
    moveto(185,260);
    delay(20);
    sound(600);
    delay(30);
    outtext("Email: gbsahoo@yahoo.com");
    nosound();
    moveto(10,450);
    cin.get();
    closegraph();  //closing graphics screen
}

//----------------------------------------------------------------------------
// Function for screen setting
//----------------------------------------------------------------------------
void border()
{
    clrscr();
    textcolor(WHITE);
    for (int i=2;i<80;i++)     //drawing horizontal lines
    {
        gotoxy(i,3);
        cprintf("-");
        gotoxy(i,23);
        cprintf("-");
    }
    for (i=4;i<23;i++)         //drawing vertical lines
    {
        gotoxy(2,i);
        cprintf("|");
        gotoxy(79,i);
        cprintf("|");
    }
}

//----------------------------------------------------------------------------
// Main program
//----------------------------------------------------------------------------

void main()
{
    clrscr();
    void highvideo();   //setting the intensity of text charaters to high
    welcome();          // calling the function for making the cover page
    remove("sale.dat");
    int n;
    char l='y';
    do
    {
        textcolor(LIGHTGREEN);
        border();       //making the border of the screen
        textcolor(LIGHTGREEN);
        gotoxy(30,5);
        cprintf("MAIN MENU");
        for (int z=29;z<=40;z++)
        {
            gotoxy(z,6);
            cprintf("-");
        }
        gotoxy(20,7);
        cprintf("1:ADD NEW PRODUCTS");
        gotoxy(20,8);
        cprintf("2:ADD NEW MEMBERS");
        gotoxy(20,9);
        cprintf("3:VIEW AN EXISTING PRODUCT RECORD ");
        gotoxy(20,10);
        cprintf("4:VIEW AN EXISTING MEMBER'S RECORD ");
        gotoxy(20,11);
        cprintf("5:BILLING ");
        gotoxy(20,12);
        cprintf("6:TODAY'S SALES ");
        gotoxy(20,13);
        cprintf("7:MODIFY PRODUCT RECORD ");
        gotoxy(20,14);
        cprintf("8:MODIFY MEMBER'S RECORD ");
        gotoxy(20,15);
        cprintf("9:INSTRUCTIONS ");
        gotoxy(20,16);
        cprintf("0:EXIT");
        gotoxy(20,19);
        cprintf("Enter your choice:");
        cin>>n;
        switch(n)
        {
            case 1:    products_enter();
                break;
            case 2:    members_enter();
                break;
            case 3:    readp();
                break;
            case 4:    readm();
                break;
            case 5:    billing();
                break;
            case 6:    sales();
                break;
            case 7:    modifyp();
                break;
            case 8:    modifym();
                break;
            case 9:    instructions();
                break;
            case 0:    l='n';
        }
    } while (l=='y');
    clrscr();
}

//----------------------------------------------------------------------------
// Function for getting the products' records
//----------------------------------------------------------------------------
void products_enter()
{
    int q=0;
    char l='y';
    pro1.open("products.dat",ios::in);  //opening file in stream
    pro1.seekg(0,ios::end);  //determining end of file
    q=pro1.tellg()/sizeof(products_record);  //finding size of file
    q+=1255;
    pro1.close();
    pro1.open("products.dat" ,ios::app);

    do
    {
        textcolor(LIGHTBLUE);
        clrscr();
        border();
        textcolor(LIGHTBLUE);
        gotoxy(28,2);
        cprintf("ENTERING PRODUCT RECORDS ");
        gotoxy(15,6);
        cprintf("Name :");
        gets(ob1.name);
        if (!ob1.name[0])           //to undo entering if name is not entered
            return;
        gotoxy(15,7);
        cprintf("Stock :");
        cin>>ob1.stock;
        gotoxy(15,8);
        cprintf("Rate (Rs.):");
        cin>>ob1.rate;
        ob1.no = q++;
        gotoxy(15,9);
        cprintf("Number :");
        cout<<ob1.no;
        pro1.write((char*)&ob1,sizeof(products_record));
        gotoxy(10,15);
        cprintf("Do you want to enter more (Y/N) ");
        l=getch();
    } while (tolower(l)=='y');
    pro1.close();
}

//--------------------------------------------------------------
//Function for searching in the file
//--------------------------------------------------------------
products_record products_search(int no)
{
    fstream pro1; //declaring stream
    pro1.open("products.dat" ,ios::in||ios::nocreate); //opening the file
    while(pro1)
    {
        pro1.read((char*)&ob1,sizeof(products_record));
        //reading from file
        if (ob1.no==no)
            return ob1;   //returning the searched record
    }
    pro1.close();
    ob1.no=0;
    return ob1;
}

//----------------------------------------------------------------------------
//Function for modifying records
//----------------------------------------------------------------------------
void products_modify(int no)
{
    ob2.no=0;
    pro1.open("products.dat",ios::in);  //opening the file
    pro2.open("product1.dat",ios::app); //opening another file
    pro1.seekg(0,ios::beg);    //locating beggining of file
    pro1.read((char*)&ob1,sizeof(products_record));
    //reading from file
    while (!pro1.eof() )      //testing for end of file
    {
        if (ob1.no!=no )
            pro2.write((char*)&ob1,sizeof(products_record));
            //writing in file
        else
            ob2=ob1;
        pro1.read((char*)&ob1,sizeof(products_record));
        //reading from file
    }
    //displaying previous reccords and entering new records
    if (ob2.no)
    {
        gotoxy(13,7);
        cprintf("CURRENT RECORDS ARE ");
        gotoxy(15,8);
        cprintf("NAME :");
        puts(ob2.name);
        gotoxy(15,9);
        cprintf("RATE :(Rs.)");
        cout<<ob2.rate;
        gotoxy(15,10);
        cprintf("STOCK :");
        cprintf("%d",ob2.stock);
        gotoxy(13,12);
        cprintf("ENTER NEW PRODUCT RECORDS");
        gotoxy(15,13);
        cprintf("NAME :");
        ob1.no=ob2.no;
        gets(ob1.name);
        if (!isalnum(ob1.name[0]))    //testing for an entry
            strcpy(ob1.name,ob2.name);   //retaining previous name when no entry
        gotoxy(15,14);
        cprintf("RATE :(Rs.)");
        cin>>ob1.rate;
        if (!ob1.rate)
             ob1.rate=ob2.rate;
        gotoxy(15,15);
        cprintf("STOCK :");
        cin>>ob1.stock;
        if (!ob1.stock)
            ob1.stock=ob2.stock;
        pro2.write((char*)&ob1,sizeof(products_record)); //writing in file
    }
    else
    {
        gotoxy(20,9);
        cprintf("NO ENTRY\a");
    }
    pro1.close(); //closing file
    pro2.close(); //closing file
    remove ("products.dat");     //deleting file
    rename ("product1.dat","products.dat");     //renaming file
}

//----------------------------------------------------------------------------
// Function to enter members' records
//----------------------------------------------------------------------------
void members_enter()
{
    int m;
    char l='y';
    //determining number of enteries in the file
    mem1.open("members.dat",ios::in);
    mem1.seekg(0,ios::end);
    m=mem1.tellg()/sizeof(members_record);
    mem1.close();
    m+=10;
    clrscr();
    mem1.open("members.dat",ios::app);        //opening file
    do
    {
        textcolor(LIGHTCYAN);
        clrscr();
        border();
        textcolor(LIGHTCYAN);
        gotoxy(28,2);
        cprintf("ENTERING MEMBER RECORDS ");
        gotoxy(15,6);
        cprintf("Name :");
        gets(m1.name);
        if (!m1.name[0])
            return; //undo entering when no name is entered
        gotoxy(15,7);
        cprintf("Card number :");
        cin>>m1.card;
        gotoxy(15,8);
        cprintf("Address :");
        gets(m1.add);
        gotoxy(15,9);
        cprintf("Tel. :");
        cin>>m1.tel;
        gotoxy(15,10);
        cprintf("Amount Deposited (Rs.):");
        cin>>m1.amt;
        if (m1.amt<=100)
        {
            gotoxy(15,11);
            cprintf("Amount less\a");
            gotoxy(15,12);
            cprintf("Try Again");
            goto end;
        }
        m1.no = m++;
        gotoxy(15,11);
        cprintf("Membership number :");
        cout<<m1.no;
        mem1.write((char*)&m1,sizeof(members_record));   //writing in file
        end:
        gotoxy(10,15);
        cprintf("Do you want to enter more (Y/N) ");
        l=getch();
    } while (tolower(l)=='y');
    mem1.close();
}

//----------------------------------------------------------------------------
// Function for searching in the file
//----------------------------------------------------------------------------
members_record members_search(int no)
{
    fstream mem2; //declaring stream
    mem2.open("members.dat",ios::in);       //opening file
    while (mem2)
    {
        mem2.read((char*)&m1,sizeof(members_record));   //reading from file
        if (m1.no==no)
            return m1;  //returning the searched record
    }
    mem2.close();
    m1.no=0;
    return m1;
}

//----------------------------------------------------------------------------
// Function to modify members' records
//----------------------------------------------------------------------------
void members_modify(int no)
{
    m2.no=0;
    mem1.open("members.dat",ios::in);        //opening a file
    mem2.open("member1.dat",ios::app);       //opening another file
    mem1.seekg(0,ios::beg);
    mem1.read((char*)&m1,sizeof(members_record));
    while (!mem1.eof())                     //testing for end of file
    {
        if (m1.no!=no)
            mem2.write((char*)&m1,sizeof(members_record));
        else
            m2=m1;
        mem1.read((char*)&m1,sizeof(members_record));
    }
    //displaying current records and entering new records
    if (m2.no)
    {
        gotoxy(13,7);
        cprintf("CURRENT RECORDS ARE ");
        gotoxy(15,8);
        cprintf("NAME :");
        puts(m2.name);
        gotoxy(15,9);
        cprintf("CARD NUMBER :");
        cout<<m2.card;
        gotoxy(15,10);
        cprintf("ADDRESS :");
        puts(m2.add);
        gotoxy(15,11);
        cprintf("TELEPHONE :");
        cout<<m2.tel;
        gotoxy(15,12);
        cprintf("AMOUNT :(Rs.)");
        cout<<m2.amt;
        gotoxy(13,14);
        cprintf("ENTER NEW RECORDS");
        gotoxy(15,15);
        cprintf("NAME :");
        m1.no=m2.no;
        gets(m1.name);
        if (!m1.name[0])
            strcpy(m1.name,m2.name);
        gotoxy(15,16);
        cprintf("ADDRESS :");
        gets(m1.add);
        if (!m1.add[0])
            strcpy(m1.add,m2.add);
        gotoxy(15,17);
        cprintf("CARD NUMBER :");
        cin>>m1.card;
        if (!m1.card)
            m1.card=m2.card;
        gotoxy(15,18);
        cprintf("TELEPHONE :");
        cin>>m1.tel;
        if (!m1.tel)
            m1.tel=m2.tel;
        gotoxy(15,19);
        cprintf("AMOUNT ADDED :(Rs.)");
        cin>>m1.amt;
        m1.amt+=m2.amt;
        mem2.write((char*)&m1,sizeof(members_record));
    }
    else
    {
        gotoxy(20,10);
        cprintf("NO ENTRY\a");
    }
    mem1.close();       //closing file
    mem2.close();       //closing file
    remove ("members.dat");        //removing file
    rename ("member1.dat","members.dat");        //renaming file
}

//----------------------------------------------------------------------------
// Function for reading product records
//----------------------------------------------------------------------------
void readp()
{
    char l='y';
    do
    {
        textcolor(LIGHTBLUE);
        clrscr();
        border();
        textcolor(LIGHTBLUE);
        gotoxy(28,2);
        cprintf("VIEWING PRODUCT RECORDS ");
        gotoxy(15,6);
        cprintf("Enter product number:");
        int no;
        cin>>no;
        ob1=products_search(no);           //calling for search in the file
        // displaying records
        if (ob1.no)
        {
            gotoxy(18,9);
            cprintf("The record is");
            gotoxy(20,10);
            cprintf(" Number :");
            cout<<ob1.no;
            gotoxy(20,11);
            cprintf(" Stock :");
            cout<<ob1.stock;
            gotoxy(20,12);
            cprintf(" Name : ");
            puts(ob1.name);
            gotoxy(20,13);
            cprintf(" Rate :(Rs.)");
            cout<<ob1.rate;
        }
        else
        {
            gotoxy(20,10);
            cprintf("NO ENTRY \a");
        }
        gotoxy(15,16);
        cprintf("Any more records desired (Y/N)");
        l=getch();
    } while(tolower(l)=='y');
}

//----------------------------------------------------------------------------
// Function to pruduce screen for 'modify product records'
//----------------------------------------------------------------------------
void modifyp()
{
    char l='y';
    do
    {
        textcolor(LIGHTBLUE);
        clrscr();
        border();
        textcolor(LIGHTBLUE);
        gotoxy(25,2);
        cprintf("MODIFYING A PRODUCT RECORD");
        gotoxy(15,5);
        cprintf("Enter the product number:");
        int no;
        cin>>no;
        products_modify(no);         //calling for modifications
        gotoxy(13,20);
        cprintf("Any more modifications desired(Y/N)");
        l=getch();
    } while (tolower(l)=='y');
}

//----------------------------------------------------------------------------
// Function to read members' records
//----------------------------------------------------------------------------
void readm()
{
    char l='y';
    do
    {
        textcolor(LIGHTCYAN);
        clrscr();
        border();
        textcolor(LIGHTCYAN);
        gotoxy(25,2);
        cprintf("VIEWING A MEMBER'S RECORD ");
        gotoxy(15,6);
        cprintf("Enter membership number:");
        int no;
        cin>>no;
        m1=members_search(no);          //calling for search
        //displaying records
        if (m1.no)
        {
            gotoxy(18,9);
            cprintf("The record is");
            gotoxy(20,10);
            cprintf("Number :");
            cout<<m1.no;
            gotoxy(20,11);
            cprintf("Name :");
            puts(m1.name);
            gotoxy(20,12);
            cprintf("Card number :");
            cout<<m1.card;
            gotoxy(20,13);
            cprintf("Address :");
            puts(m1.add);
            gotoxy(20,14);
            cprintf("Telephone :");
            cout<<m1.tel;
            gotoxy(20,15);
            cout<<"Amount :(Rs.)"<<m1.amt;
        }
        else
        {
            gotoxy(17,12);
            cprintf("NO ENTRY\a ");
        }
        gotoxy(15,18);
        cprintf("Any more records desired (Y/N)");
        l=getch();
    } while(tolower(l)=='y');
}

//----------------------------------------------------------------------------
// Function to display screen for 'modify members' records
//----------------------------------------------------------------------------
void modifym()
{
    char l='y';
    do
    {
        textcolor(LIGHTCYAN);
        clrscr();
        border();
        gotoxy(25,2);
        cprintf("MODIFYING MEMBER'S RECORDS ");
        gotoxy(15,5);
        cprintf("Enter the membership number:");
        int no;
        cin>>no;
        members_modify(no);          //calling for modifications
        gotoxy(13,22);
        cprintf("Any more modifications desired(Y/N)");
        l=getch();
    } while(tolower(l)=='y');
}

//----------------------------------------------------------------------------
// Function for creating 'sale.dat'
//----------------------------------------------------------------------------
// Function for billing
//----------------------------------------------------------------------------
void billing()
{
    textcolor(LIGHTRED);
    clrscr();
    border();
    textcolor(LIGHTRED);
    fstream b1;                   //declaring stream
    b1.open("sale.dat",ios::app);    //opening file
    gotoxy(30,2);
    cprintf("BILLING ");
    gotoxy(15,7);
    cprintf("Are you a member(Y/N):");
    float less=1.0;
    char m;
    int no;
    long card;
    m=getche();
    if (tolower(m)=='y')
    {
        gotoxy(18,9);
        cprintf("Enter membership number:");
        cin>>no;
        gotoxy(18,10);
        cprintf("Enter card number:");
        cin>>card;
        m1=members_search(no);
        if (card!=m1.card)         //checking for authenticity of the details
        {
            gotoxy(20,12);
            cprintf("Incorrect \a");
            getch();
            return;                  //undoing billing process
        }
        else
        if (m1.amt>100)
        {
            less=0.95;
            m1.amt-=5;
        }
        else
        {
            gotoxy(20,12);
            cprintf("Amount Less\a");
            gotoxy(15,15);
            cprintf("Continue with normal billing(Y/N)");
            m=getch();
            if (tolower(m)=='n')
                return;
        }
        //decreasing the members' amount if the details are correct
        fstream t3,t4;
        t3.open("members.dat",ios::in);
        t4.open("member1.dat",ios::app);
        t3.seekg(0,ios::beg);
        t3.read((char*)&m2,sizeof(members_record));
        while (!t3.eof())
        {
            if (m2.no!=m1.no)
                t4.write((char*)&m2,sizeof(members_record));
            else
                t4.write((char*)&m1,sizeof(members_record));
            t3.read((char*)&m2,sizeof(members_record));
        }
        t3.close();
        t4.close();
        remove("members.dat");
        rename("member1.dat","members.dat");
    }
    clrscr();
    float total=0.0;
    textcolor(LIGHTGREEN);
    gotoxy(60,1);
    cprintf("p.no.= 0:Exit Billing");
    textcolor(LIGHTRED);
    gotoxy(30,1);
    cprintf("BILLING");
    i=0;
    void table1();         //function declaration for making table
    beg:                    //giving line a name for further reference
    table1();              //calling function for making table
    gotoxy(4,6+i);
    cin>>n1.no;
    ob1=products_search(n1.no);     //searching for product record
    gotoxy(56,6+i);
    float output1(products_record);  //declaring a nested function
    if (n1.no>0)
    {
        if(ob1.no>0)
        {
            cin>>n1.qty;
            strcpy(n1.name,ob1.name);
            n1.rate=ob1.rate;
            n1.total=output1(ob1);
            total+=n1.total;
            fstream t3,t4;
            t3.open("sale.dat",ios::in);
            t4.open("sale1.dat",ios::app);
            t3.seekg(0,ios::beg);
            int qty=n1.qty;
            n1.qty=n1.total/n1.rate;
            char test='y';
            t3.read((char*)&n2,sizeof(tables));
            while (!t3.eof())
            {
                if (n1.no==n2.no)
                {
                    n2.qty+=n1.qty;
                    n2.total+=n1.total;
                    test='n';
                }
                t4.write((char*)&n2,sizeof(tables));
                t3.read((char*)&n2,sizeof(tables));
            }
            if (test=='y')
            {
                t4.seekg(0,ios::end);
                t4.write((char*)&n1,sizeof(tables));
            }
            t3.close();
            t4.close();
            remove("sale.dat");
            rename("sale1.dat","sale.dat");
            n1.qty=qty;
            if (n1.total)
            {
                //reducing the products' stock
                fstream temp3,temp4;
                temp3.open("products.dat",ios::in);
                temp4.open("product1.dat",ios::app);
                temp3.seekg(0,ios::beg);
                temp3.read((char*)&ob1,sizeof(products_record));
                while (!temp3.eof())
                {
                    if (ob1.no==n1.no)
                        ob1.stock-=n1.qty;
                    temp4.write((char*)&ob1,sizeof(products_record));
                    temp3.read((char*)&ob1,sizeof(products_record));
                }
                temp3.close();
                temp4.close();
                remove("products.dat");
                rename("product1.dat","products.dat");
            }
            i++;
            goto beg;
        }
        else
            if (ob1.no==0)
            {
                gotoxy(10,6+i);
                cprintf("No entry\a");
                i++;
                goto beg;
            }
    }
    else
        if (n1.no==0)
        {
            textcolor(WHITE);
            for (int j=0;j<81;j++)          //ending table
            {
                gotoxy(j,6+i);
                cprintf("-");
            }
        }
        textcolor(LIGHTRED);
        gotoxy(5,9+i);
        cprintf("Number of items = ");
        cout<<i;
        gotoxy(5,10+i);
        cprintf("Grand total = Rs.");
        cout<<total;
        //giving discount
        if (less!=1)
        {
            discount+=0.05*total;
            gotoxy(5,12+i);
            cprintf("Discount = Rs.");
            cout<<0.05*total;
            gotoxy(5,13+i);
            cprintf("Net total = Rs.");
            cout<<less*total;
        }
        b1.close();
        getch();
}
//----------------------------------------------------------------------------
// nested function of 'billing'
//----------------------------------------------------------------------------
float output1(products_record ob1)
{
    if (ob1.no==0)    //if no entry then return to billing
    return 0;
    float stotal;
    stotal=ob1.rate*n1.qty; //determining the cost of the particular item
    //putting the values on the screen
    gotoxy(4,6+i);
    cout<<ob1.no;
    gotoxy(10,6+i);
    puts(ob1.name);
    gotoxy(38,6+i);
    cout<<ob1.rate;
    gotoxy(43,6+i);
    cout<<"     ";
    gotoxy(56,6+i);
    if (n1.qty>ob1.stock)     //checking for the item being in stock
    {
        gotoxy(50,6+i);
        cprintf("Out of stock\a");
        return 0;
    }
    cout<<n1.qty;
    gotoxy(68,6+i);
    cout<<stotal;
    gotoxy(74,6+i);
    cout<<"      ";
    return stotal;
}

//----------------------------------------------------------------------------
// Function for making table
//----------------------------------------------------------------------------
void table1()
{
    textcolor(WHITE);
    //drawing vertical lines
    for (int a=1;a<=80;a++)
    {
        gotoxy(a,2);
        cprintf("_");
        gotoxy(a,5);
        cprintf("-");
    }
    //drawing horizontal lines(always)
    for (a=3;a<=5;a++)
    {
        gotoxy(1,a);
        cprintf("|");
        gotoxy(9,a);
        cprintf("|");
        gotoxy(31,a);
        cprintf("|");
        gotoxy(49,a);
        cprintf("|");
        gotoxy(64,a);
        cprintf("|");
        gotoxy(80,a);
        cprintf("|");
    }
    /* drawing horizontal lines
    (depending upon the s.no. of item in purchase list)*/
    gotoxy(1,6+i);
    cprintf("|");
    gotoxy(9,6+i);
    cprintf("|");
    gotoxy(31,6+i);
    cprintf("|");
    gotoxy(49,6+i);
    cprintf("|");
    gotoxy(64,6+i);
    cprintf("|");
    gotoxy(80,6+i);
    cprintf("|");
    textcolor(LIGHTRED);
    //giving column titles
    gotoxy(2,3);
    cprintf("Product");
    gotoxy(14,3);
    cprintf("Product name ");
    gotoxy(35,3);
    cprintf("Rate (Rs.)");
    gotoxy(53,3);
    cprintf("Quantity");
    gotoxy(67,3);
    cprintf("Total (Rs.)");
    gotoxy(2,4);
    cprintf("number");
    gotoxy(53,4);
    cprintf("(Kgs/pcs)");
}

//----------------------------------------------------------------------------
// Function for viewing the day's sale
//----------------------------------------------------------------------------
void sales()
{
    textcolor(LIGHTRED);
    clrscr();
    textcolor(LIGHTRED);
    gotoxy(28,1);
    cprintf("TODAY'S SALES");
    float sales=0.0;
    fstream sal1;
    sal1.open("sale.dat",ios::in);
    i=0;
    sal1.read((char*)&n1,sizeof(n1));
    while(!sal1.eof() && n2.no!=n1.no)
    {
        table1();
        gotoxy(4,6+i);
        cout<<n1.no;
        gotoxy(10,6+i);
        puts(n1.name);
        gotoxy(38,6+i);
        cout<<n1.rate;
        gotoxy(43,6+i);
        cout<<"     ";
        gotoxy(56,6+i);
        cout<<n1.qty;
        gotoxy(68,6+i);
        cout<<n1.total;
        sales+=n1.total;
        gotoxy(74,6+i);
        cout<<"     ";
        i++;
        n2.no=n1.no;
        sal1.read((char*)&n1,sizeof(n1));
    }
    textcolor(WHITE);
    gotoxy(1,6+i);
    for(int n=1;n<=80;n++)
        cprintf("-");
    textcolor(LIGHTRED);
    gotoxy(5,8+i);
    cprintf("Grand total = Rs.");
    cout<<sales;
    gotoxy(5,10+i);
    cprintf("Discount = Rs.");
    cout<<discount;
    gotoxy(5,11+i);
    cprintf("Net total = Rs.");
    cout<<(sales-discount);
    getch();
}

//----------------------------------------------------------------------------
// Instructions
//----------------------------------------------------------------------------
// Function for help on entering records

void enter()
{
    border();
    gotoxy(5,1);
    cprintf("Entering Records");
    gotoxy(5,7);
    textcolor(11);
    cprintf("For Products");
    textcolor(13);
    gotoxy(5,10);
    cprintf("This part of the program helps the store management to ");
    cprintf("add more");
    gotoxy(5,9);
    cprintf("products to their store. The existing product records are");
    cprintf(" not ");
    gotoxy(5,10);
    cprintf("affected by this option. The new record(s) are appended at");
    cprintf(" the end");
    gotoxy(5,11);
    cprintf("of the file containing such records namely ");
    textcolor(12);
    cprintf("'products.dat'");
    textcolor(13);
    cprintf(". This");
    gotoxy(5,12);
    cprintf("option automatically assigns a product number to the product");
    cprintf(" which");
    gotoxy(5,13);
    cprintf("must be remembered for any product reference.");
    gotoxy(5,15);
    textcolor(11);
    cprintf("For members");
    textcolor(13);
    gotoxy(5,17);
    cprintf("This option works just like its counterpart for products. It");
    cprintf(" stores");
    gotoxy(5,18);
    cprintf("records in the file ");
    textcolor(12);
    cprintf("'members.dat'");
    textcolor(13);
    cprintf(" and assigns a membership number ");
    gotoxy(5,19);
    cprintf("for every new entry. For further details see the help section");
    cprintf(" on ");
    textcolor(12);
    gotoxy(5,20);
    cprintf("'Membership Rules'.");
    textcolor(13);
    getch();
}

//Function for help on viewing records

void view()
{
    border();
    gotoxy(30,5);
    cprintf("Viewing Records");
    gotoxy(10,7);
    cprintf("This option enables the user to view the latest records of ");
    gotoxy(10,8);
    cprintf("either products or members. It helps in operations like ");
    gotoxy(10,9);
    cprintf("stock checking and member verification. The viewing is");
    gotoxy(10,10);
    cprintf("only possible with the product/membership numbers.");
    getch();
}

//Function for help on modifying records
void modify()
{
    border();
    gotoxy(30,5);
    cprintf("Modifying Records");
    gotoxy(10,7);
    cprintf("This option helps in altering the records in the files.");
    gotoxy(10,8);
    cprintf("It can be used for deleting the entries as well. In ");
    gotoxy(10,9);
    cprintf("case of products either the record could be changed to");
    gotoxy(10,10);
    cprintf("some new entry or its stock could be made zero. For members");
    gotoxy(10,11);
    cprintf("deletion is only possible by overwriting with a new entry.");
    getch();
}

// Function for help on billing process
void procedure()
{
    border();
    gotoxy(30,5);
    cprintf("Billing Procedure");
    gotoxy(10,7);
    cprintf("The actual billing procedure consists of two sections.");
    gotoxy(10,8);
    cprintf("One checks if the buyer is a member or not and accordingly");
    gotoxy(10,9);
    cprintf("performs the necessary tasks. The other section consists of ");
    gotoxy(10,10);
    cprintf("billing. The user is asked to enter the product number and the ");
    gotoxy(10,11);
    cprintf("quantity bought. The computer calculates the total itself and ");
    gotoxy(10,12);
    cprintf("also the discount if necessary. In order to exit the procedure");
    gotoxy(10,13);
    cprintf("and view the final total, the user should enter the product number");
    gotoxy(10,14);
    cprintf("as '0'.");
    getch();
}

// Function for help on Membership details
void rules()
{
    border();
    gotoxy(30,5);
    cprintf("Membership Rules");
    gotoxy(5,7);
    cprintf("The program lets its subscribers (stores) maintain a");
    cprintf(" member's list");
    gotoxy(5,8);
    cprintf("in order to help them in increasing their sales for a");
    cprintf(" marginal cut");
    gotoxy(5,9);
    cprintf("in their profits. The program sets minimum membership ");
    cprintf("amount as Rs.100");
    gotoxy(5,10);
    cprintf("which must be paid at the time of registration. The member");
    cprintf(" will be ");
    gotoxy(5,11);
    cprintf("given a membership number and a membership card (to be");
    cprintf("collected ");
    gotoxy(5,12);
    cprintf("after a week by reference to the membership number and ");
    cprintf("other");
    gotoxy(5,13);
    cprintf("particulars). In case a member loses the membership card ");
    cprintf(", he/she ");
    gotoxy(5,14);
    cprintf("must register a complaint with the store by submitting a");
    cprintf(" written");
    gotoxy(5,15);
    cprintf("application with all the particulars. He/She can collect ");
    cprintf("his/her ");
    gotoxy(5,16);
    cprintf("remaining money by showing proofs of the particulars.");
    gotoxy(5,17);
    cprintf("The membership allows a person to avail a special discount");
    cprintf(" of 5%");
    gotoxy(5,18);
    cprintf("over every purchase. Rs.5 will be subtracted from the ");
    cprintf("member's account");
    gotoxy(5,19);
    cprintf("over every purchase. The account will be rendered ");
    cprintf("inaccessible if the ");
    gotoxy(5,20);
    cprintf("amount will be less than Rs.100 and the member would be");
    cprintf(" expected to ");
    gotoxy(5,21);
    cprintf("deposit more money for continuing the membership. The store");
    cprintf(" will also");
    gotoxy(5,22);
    cprintf("give away attractive gifts to a lucky member once every year.");
    getch();
}

// Functiom for help on today's sales

void today()
{
    border();
    gotoxy(30,5);
    cprintf("Today's sales");
    gotoxy(10,7);
    cprintf("This option shows the total sales in terms of both quantity");
    gotoxy(10,8);
    cprintf("and amount per item. This is stored in a file namely ");
    gotoxy(10,9);
    cprintf("'sale.dat' which is modified after every buying during the");
    gotoxy(10,10);
    cprintf("billing process.");
    getch();
}

//Function for displaying help index
void instructions()
{
    clrscr();
    int n;
    char l='y';
    do
    {
        textcolor(13);
        border();
        textcolor(13);
        gotoxy(30,5);
        cprintf("HELP INDEX");
        for (int z=29;z<=39;z++)
        {
            gotoxy(z,6);
            cprintf("-");
        }
        gotoxy(20,7);
        cprintf("1:ADD RECORDS");
        gotoxy(20,8);
        cprintf("2:VIEWING RECORDS ");
        gotoxy(20,9);
        cprintf("3:MODIFYING RECORDS");
        gotoxy(20,10);
        cprintf("4:BILLING PROCEDURE");
        gotoxy(20,11);
        cprintf("5:TODAY'S SALES ");
        gotoxy(20,12);
        cprintf("6:MEMBERSHIP DETAILS");
        gotoxy(20,13);
        cprintf("0:BACK TO MAIN MENU");
        gotoxy(21,16);
        cprintf("Enter your choice:");
        cin>>n;
        switch(n)
        {
            case 1:    enter();
                break;
            case 2:    view();
                break;
            case 3:    modify();
                break;
            case 4:    procedure();
                break;
            case 5:    today();
                break;
            case 6:    rules();
                break;
            case 0:    l='n';
        }
    } while (l=='y');
}

//---------------------------------------------------------------------------
// Function for ending screen
//----------------------------------------------------------------------------

void end()
{
    gdriver=DETECT;       //request auto detection
    initgraph(&gdriver,&gmode,"..\bgi");  //initialising graph
    /* read result of initialization */
    int errorcode = graphresult();
    if (errorcode != grOk)  /* an error occurred */
    {
        printf("Graphics error: %s\n", grapherrormsg(errorcode));
        printf("Press any key to halt:");
        getch();
        return;
    }
    setcolor(BROWN);
    setbkcolor(WHITE);
    rectangle(10,10,getmaxx()-10,getmaxy()-10);
    rectangle(15,15,getmaxx()-15,getmaxy()-15);
    settextstyle(7,0,8);
    moveto(90,75);
    outtext("THANK YOU");
    closegraph();
}

Flow of Control Assignment

 

These are the assignment for all the student who wants to check his/her strength in  looping and in branching statement.  Just try to solve and enjoy.

 

Q1. Write a program in C++ to print the following pattern on the monitor

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

Q2. Write a program in C++ to print the following pattern on the monitor

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

Q3. Write a program in c++ to print the following pattern on the monitor

1

1 0

1 0 1

1 0 1 0

1 0 1 0 1

Q5. Write a program in c++ to print the following pattern on the monitor

1

0 1

1 0 1

0 1 0 1

1 0 1 0 1

Q6. Write a program in c++ to print the following pattern on the monitor

1

1 2   2 2

1 3   2 3   3 3

Q7. Write a program in c++ to print the following pattern on the monitor

1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

Q8. Write a program in C++ to print the following pattern on the monitor

         1

      1 2 1

    1 2 3 2 1

            1 2 3 4 3 2 1

          1 2 3 4 5 4 3 2 1

Q9 Write a program in C++ to print the following pattern on the monitor

1

2 3 4

5 6 7 8 9

10 11 12 13 14 15 16

17 18 19 20 21 22 23 24 25

Q10. Write a program in C++ to print the following pattern on the monitor

1

2 3

4 5 6

7 8 9 10

11 12 13 14 15

Q11 Write a program in C++ to print the following pattern on the monitor

*

* *

* * *

* * * *

* * * * *

Q12. Write a program in C++ to print the following pattern on the monitor

                      1

                   1 2

                          1 2 3

                       1 2 3 4

                    1 2 3 4 5

                 1 2 3 4 5 6

Q13. Write a program in C++ to print the following pattern on the monitor

                                1

                             2 3

                           4 5 6

                       7 8 9 10

             11 12 13 14 15

Q14. Write a program in C++ to print the following pattern on the monitor

                                 1

                              1 2 1

                           1 2 3 2 1

                        1 2 3 4 3 2 1

                     1 2 3 4 5 4 3 2 1

                       1 2 3 4 3 2 1

                         1 2 3 2 1

                            1 2 1

                              1

Q15. Write a program in C++ to print the following pattern on the monitor

                   1 2 3 4 5 6 5 4 3 2 1

                    1 2 3 4 5 5 4 3 2 1

                      1 2 3 4 4 3 3 1

                         1 2 3 3 2 1

                            1 2 2 1

                               1 1

Q15. Write a program in C++ to print the following pattern on the monitor

             A B C D E F E D C B A

                        A B C D E E D C B A

                            A B C D D C B A

                              A B C C B A

                                 A B B A

                                    A A

Q16. Write a function to read three numbers from the keyboard and find out the largest from them?

Q17. Write a function to read three numbers from the keyboard and arrange them in ascending order (do not sort them )

Q18. Write a program in C++ to read 10 integer numbers from the keyboard and find out the sum and average of all the entered numbers

Q.19 Write a program in C++ to read 10 numbers from the keyboard and find out the largest number from them?

Q20. Write a program in C++ to read 10 numbers from the keyboard and find out the largest and lowest numbers from them

Q21. Write a program in C++ to read 10 numbers from the keyboard and find out the largest and second largest number from them.

Q22. Write a program in C++ to read an integer number and find out the sum of it’s digits?

Q23. Write a program in C++ to read an integer number and find out the reverse of the digits?

Example Number = 1234 result is = 4321

Q24. Write a program in C++ to read a number and check if the entered number is Armstrong or not ?

Q25. Write a program in C++ to find out all the Armstrong numbers between 1 and 1000.

Q26 Write a program in C++ to read a number and check if it is palindrome or not.

Q27. Write a program in C++ to find out all the palindrome number between 100 and 500.

Q28. Write a program in C++ to read a binary number and convert this number in to its equivalent decimal number

Q29. Write a program in C++ to read a number and check if it is auto morphic or not . if it is automorphic

display a proper message on the sceen.( A number when multiplied by it self , the resultant number contains the last digits of the original number )

Example ( 5 )2 = 2 5

( 6) 2 = 36

(25 )2 = 625

Q30 Write a program in C++ to read a number and check if it is prime or not ?

Q31 Write a program in C++ find out all the prime number between 100 and 200

Q32 Write a program in C++ to read a number and find out all the odd prime factor of a given number?

Q33 Write a program in C++ to read a number from the keyboard and find out the factorial of this given integer Number

Q34. Write a program in C++ to read two numbers from the keyboard and find out the largest from them?

Q35 Write a program in C++ to read three numbers and find out the largest among them?

Q36 Write a program in C++ to read the total marks obtained by a student in a subject . Find out the Grade of  the student in that subject. The criteria for calculating grades is as follows

Marks obtained Grade

>= 90 A1

< 90 and >=80 A2

<80 AND >=70 B1

< 70 AND > = 60 B2

< 60 C1

Q37. Write a program in C++ to read the total number of electricity unit consumed by the consumer . The tariff  plan for the bill is as follows

Unit Rate/Unit(Rs.)

<=100 1.00

> 100 and < = 200 2.50

>200 and < = 400 3.00

> 400 4.10

calculate the total bill, consumer have to pay?

Q38. Write a program in C++ to read a number from the keyboard and display the corresponding day of the week.

Example : If user enters 2 . Computers print : Tuesday

If user enters 7 . Computers print : Sunday

Q39. Write a program to read a year and check if it is Leap year or not ?

Q40. Write a program to read a number from the keyboard and find out the factorial of the given number?

Q41 Write a program in C++ to read two numbers X and Y and find out XY. ( Do not use built in library

function)

Q42 Write a program in C++ to print the following series on the monitor

1,2,3,4,5,6,7,…………………………………………………………………10000

Q43 Write a program in C++ to print the following series on the monitor

2,4,6,,8,10……………………………………………………………………10000

Q44. Write a program in C++ to print the following series on the monitor

1,3,5,7,9………………………………………………………………………999

Q45 Write a program in C++ to print the following series on the monitor

1,5,9,13……………………………………………………………………….999

Q46 Write a program in C++ to print the following series on the monitor

1,4,9,16……………………………………………………………………….100

Q47. Write a program in C++ to print the following series on the monitor

1,8,27,64……………………………………………………………………..1000

Q49. Write a program in C++ to print every integer between 1 and N divisible by M. Also report whether that

number is even or odd.

Q50. Write a program in C++ to find the sum of the following series

S = 1+x+x2+x3+x4+……………………………….xn

Student Report Card Generator computer science student

Student Report Card Generator cpp project for class 12 Computer Science student.  This class 12 computer project contains all the desired information required by a computer project to submit in CBSE practical examination, i,e. Classes, File Handing, Data Structure.

Note : Kindly note that this project is developed using Turbo C++ 3.0  Editor for DOS.  You are required to copy this code into NOTEPAD and save the same in CPP extension on your hard disk.

Source code for : Student Report Card Generator

#include <stdlib.h>
#include <conio.h>
#include <fstream.h>
#include <iostream.h>
#include<stdio.h>
#include<graphics.h>
#include<dos.h>
#include<string.h>

int op,rol;     //Global Variable
class student
    {
     public:
          char name[30],fname[20];
          int age;
          int subno;
          char subname[5][10];
          int cls;
          int mark[10],maxmark[20],roll,maxtotal,total;
          float avg,per;
          char grade[2],grade1[2];
          int rank;
      student()               //Constructor
         {
          strcpy(grade,"P");
          strcpy(grade1,"P");
         }
      void enter();
      void reading();
      void writing();
      void display();
      int check(int,int);
      void copy(int);
    };

int pass(int s,int m)  //to find the average
   {
     return((s*100)/m);
   }
void student::enter()       //to read the details of students
  {
    setbkcolor(CYAN);
    int x=5,y=13,a=20,z=13,b=35,c=13;
    again:cleardevice();
    rectangle(70,65,375,65);
    gotoxy(10,4);
    settextstyle(4,0,1);
    outtextxy(170,10,"ENTER STUDENT DETAILS");
    rectangle(10,40,620,420);
    outtextxy(18,40,"Name");
    gets(name);
    gotoxy(18,6);
    line(130,100,350,100);
    outtextxy(18,75,"Father Name");
    gets(fname);
    line(425,65,455,65);
    gotoxy(55,4);
    settextstyle(4,0,1);
    outtextxy(390,40,"Age");
    cin>>age;
    gotoxy(10,8);
    settextstyle(4,0,1);
    line(65,130,90,130);
    outtextxy(18,105,"Class");
    cin>>cls;
    gotoxy(22,8);
    settextstyle(4,0,1);
    line(160,130,190,130);
    outtextxy(120,105,"Roll");
    cin>>roll;
    total=0;
    settextstyle(4,0,1);
    gotoxy(28,10);
    line(205,162,230,162);
    outtextxy(18,135,"Enter the no of subject");
    cin>>subno;
    outtextxy(18,160,"Subject");
    for(int i=0;i<subno;i++)
      {
      gotoxy(x,y);
      cin>>subname[i];
      y++;
      }
    outtextxy(100,160,"Enter the marks");
    total=0;maxtotal=0;
    for( i=0;i<subno;i++)
      {
      gotoxy(a,z);
      cin>>mark[i];
      total+=mark[i];
      z++;
      }
     int r;
     outtextxy(240,160,"Enter the maxmarks");
     for( i=0;i<subno;i++)
      {
       gotoxy(b,c);
       cin>>maxmark[i];
       maxtotal+=maxmark[i];
       r=pass(mark[i],maxmark[i]);
       if(r<35)
     {
         strcpy(grade,"F");
         strcpy(grade1,"F");
     }
    c++;
    }
      avg=r;
      if(check(roll,cls)==0)        //Checking for exsisting records
       {     cleardevice();
         outtextxy(150,90,"Already Exists");
         delay(1000);
         getch();
         goto again;
    }
       }
void student::display()  //To display the details
      {
    cleardevice();
    settextstyle(7,0,1);
    char agee[20],classs[20],rolll[20],totall[20],avgg[20];
    itoa(age,agee,10);
    itoa(cls,classs,10);
    itoa(roll,rolll,10);
    itoa(total,totall,10);
    itoa(avg,avgg,10);
    outtextxy(18,40,"Name");
    outtextxy(100,40,name);
    outtextxy(18,80,"Roll");
    outtextxy(100,80,rolll);
    outtextxy(18,120,"Age");
    outtextxy(100,120,agee);
    outtextxy(18,160,"Class");
    outtextxy(100,160,classs);
    outtextxy(18,200,"Total");
    outtextxy(100,200,totall);
    outtextxy(18,240,"Average");
    outtextxy(100,240,avgg);
    getch();
      }
int student::check(int r,int c) //seraching records from a file
   {
       student s;
       ifstream in("stude.dat",ios::binary);
       while(in.read((char *)&s,sizeof(s)))
     {
      if(s.roll==r && s.cls==c)
        {
         in.close();
         return 0;
         }
      if(in.eof())
         break;
       }
     in.close();
     return 1;
    }
void student::writing()  // Write the records in to the file
    {
       cleardevice();
       ofstream out("stude.dat",ios::app|ios::binary);
       student s;
       s.enter();
       out.write((char *)&s,sizeof(s));
       out.close();
    }
void student::reading()   //Reading records from a file
   {
       student s;
       cleardevice();
       ifstream in("stude.dat",ios::binary);
       int f=0;
       while(in.read((char *)&s,sizeof(s)))
     {
     f=1;
     s.display();
     if (in.eof())
        break;
     }
     if(f==0)
         outtextxy(150,90,"No record exixt");
     getch();
     in.close();
   }
void rep_disp()   //To display report card
{
    student s;
    int f=0;
    ifstream in("reportt.dat",ios::binary);
    while(in.read((char *)&s,sizeof(s)))
       {
     if(s.roll==rol)
    {
     f=1;
     char agee[20],classs[20],rolll[20],totall[20],maxtotall[20],gradee[20];
     cleardevice();
     setlinestyle(SOLID_LINE,1,1);
     rectangle(0,0,getmaxx(),getmaxy());
     rectangle(0,10,getmaxx(),getmaxy()-10);
     outtextxy(140,70,"BIKANER");
     delay(1000);
     outtextxy(270,70," BOYS ");
     delay(1000);
     outtextxy(360,70," SCHOOL");
     delay(1000);
     outtextxy(180,100,"(Senior Secondary School)");
     delay(1000);
     outtextxy(180,170,"PROGRESS    REPORT");
     delay(1000);
     outtextxy(210,200,"2005-2006");
     setcolor(6);
     outtextxy(140,270,"\"Good education is a real treasure\"");
     delay(1000);
     cleardevice();
     setcolor(15);
     setlinestyle(DOTTED_LINE,1,1);
     outtextxy(140,10,"BIKANER BOYS SCHOOL,BIKANER");
     rectangle(10,40,620,420);
     line(75,65,350,65);
     outtextxy(18,40,"Name");
     setcolor(4);
     outtextxy(85,40,strupr(s.name));
     setcolor(15);
     line(150,100,350,100);
     outtextxy(18,75,"Father Name");
     setcolor(4);
     outtextxy(160,75,strupr(s.fname));
     setcolor(15);
     line(425,65,465,65);
     outtextxy(390,40,"Age");
     itoa(s.age,agee,10);
     setcolor(4);
     outtextxy(430,40,agee);
     setcolor(15);
     line(65,130,100,130);
     outtextxy(18,105,"Class");
     itoa(s.cls,classs,10);
     setcolor(4);
     outtextxy(73,105,classs);
     setcolor(15);
     line(160,130,190,130);
     outtextxy(120,105,"Roll");
     itoa(s.roll,rolll,10);
     setcolor(4);
     outtextxy(165,105,rolll);
     setcolor(15);
     outtextxy(20,155,"Subject");
     outtextxy(170,155,"Marks");
     outtextxy(300,155,"Max. Marks");
     setcolor(4);
     int x=20,y=185,a=190,z=185,b=335,c=185;
     char markk[30],maxx[30];
     for(int i=0;i<s.subno;i++)
        {
        gotoxy(x,y);
        itoa(s.mark[i],markk,10);
        itoa(s.maxmark[i],maxx,10);
        outtextxy(x,y,strupr(s.subname[i]));
        outtextxy(a,z,markk);
        outtextxy(b,c,maxx);
        y+=20;
        z+=20;
        c+=20;
        }
     setcolor(15);
     itoa(s.total,totall,10);
     outtextxy(x,y+30,"Total");
     setcolor(4);
     outtextxy(a,z+30,totall);
     itoa(s.maxtotal,maxtotall,10);
     outtextxy(b,c+30,maxtotall);
     setcolor(15);
     outtextxy(480,230,"Grade");
     setcolor(4);
     outtextxy(540,230,s.grade1);
     setcolor(15);
     itoa(s.rank,maxtotall,10);
     outtextxy(480,270,"Rank");
     setcolor(4);
     outtextxy(540,270,maxtotall);
     setcolor(15);
     outtextxy(480,155,"Comment");
     setcolor(4);
     if(strcmp(s.grade,"P")==0)
         {
          if(s.avg>=90)
        outtextxy(470,185,"Exceptional");
          else
        if(s.avg>=80 && s.avg<90)
          outtextxy(470,185,"Excellent");
          else
        if(s.avg>=70 && s.avg<80)
          outtextxy(470,185,"Good");
          else
        if(s.avg>=60 && s.avg<70)
           outtextxy(470,185,"Not Bad");
           else
         if(s.avg<60)
            outtextxy(470,185,"Very less");
         }
        else
          outtextxy(450,185,"Work very hard");
        break;
       }
     }
    setcolor(15);
    if(f==0)
       outtextxy(150,90,"Not found");
    getch();
    in.close();
    }
void top(student s)   //To display the details of topper
  {
    char chh,classs[20];
    cleardevice();
    gotoxy(10,2);
    setlinestyle(DOTTED_LINE,1,1);
    rectangle(90,90,500,300);
    line(420,180,490,180);
    line(420,230,470,230);
    settextstyle(4,0,4);
    setcolor(4);
    outtextxy(170,100,"CERTIFICATE") ;
    setcolor(15);
    settextstyle(4,0,2);
    outtextxy(100,150,"\"This to certify that Master/Miss") ;
    setcolor(4);
    outtextxy(430,150,s.name);
    setcolor(15);
    outtextxy(100,200, "has shown excellent performance in" );
    itoa(s.cls,classs,10);
    setcolor(4);
    outtextxy(430,200,classs);
    setcolor(15);
    outtextxy(470,200,"\"");
    gotoxy(10,3);
    settextstyle(4,0,1);
    getch();
   }
void arrange(student s[],int n)   //Arrange the records based on their total
  {
   int i,j;
   student t,cd[100];
   ofstream out("reportt.dat",ios::binary);
   for(i=0;i<n;i++)
    for(j=i+1;j<n;j++)
     {
      if(s[i].total<s[j].total)
     {
          t=s[i];
          s[i]=s[j];
          s[j]=t;
      }
       }
     int k=1;
     for(i=0;i<n;i++)
      {
    if(strcmp(s[i].grade,"P")==0)
       {
        if(s[i].avg>=90)
            strcpy(s[i].grade1,"A");
        else
        if(s[i].avg>=80 && s[i].avg<90)
            strcpy(s[i].grade1,"B");
        else
        if(s[i].avg>=70 && s[i].avg<80)
            strcpy(s[i].grade1,"C");
        else
        if(s[i].avg>=60 && s[i].avg<70)
            strcpy(s[i].grade1,"D");
        else
        if(s[i].avg<60)
            strcpy(s[i].grade1,"E");
        s[i].rank=k++;
        }
        else
        s[i].rank=0;
        out.write((char *)&s[i],sizeof(s[i]));
         }
          out.close();
          if(op==3)
         rep_disp();
           else
         if(op==4)
           top(s[0]);
         else if(op==6)
           {
           student t;
           int r=0,x=130,y=130;
           cleardevice();
           outtextxy(210,50,"Rank List");
           outtextxy(180,90,"S.No");
           outtextxy(300,90,"Name");
           ifstream in("reportt.dat",ios::binary);
           int i=0;
           char ch[2];
           while(in.read((char *)&t,sizeof(t)))
             {
             i++;
             itoa(i,ch,10);
             outtextxy(180,x,ch);
             outtextxy(300,y,t.name);
             x+=20;
             y+=20;
             if(in.eof())
              break;
              }
          getch();
          in.close();
          }
         }
void student::copy(int c)
    {
    student t[100],s;
    int i=0,f=0;
    ifstream in("stude.dat",ios::binary);
    cleardevice();
    if(op==5)
      {
    outtextxy(210,50,"Failure Details");
    outtextxy(180,90,"S.No");
    outtextxy(300,90,"Name");
       }
    int r=0,x=130,y=130;
    char ch[20];
    while(in.read((char *)&s,sizeof(s)))
      {
     if(s.cls==c)
         {
             t[i++]=s;
             f=1;
          }
      if(op==5 && s.cls==c && strcmp(s.grade,"F")==0)
         {
              r++;
              itoa(r,ch,10);
              outtextxy(180,x,ch);
              outtextxy(300,y,s.name);
              x+=20;
              y+=20;
          }
         }
     in.close();
     if(f==1)
       arrange(t,i);
     else
    outtextxy(150,90,"Not found");

    }
    void than()
    {
      for(int h=0;h<16;h++)
      {
    cleardevice();
    setcolor(h);
    settextstyle(4,0,4);
    outtextxy(200,90,"Thank You");
    outtextxy(180,150,"God bless us all");
    outtextxy(100,200,"Inspiration is the key to success");
    delay(100);
      }
     getch();
     exit(0);
     }
void main()
    {
    student s;
    int cs;
    int gdriver = DETECT, gmode, errorcode;
    initgraph(&gdriver, &gmode, "../bgi");
    for(int j=0;j<180;j+=5)
     {
    setcolor(j);
    outtextxy(j,200,"Vishal");
    delay(100);
    cleardevice();
    setbkcolor(CYAN);
    settextstyle(4,0,4);
    outtextxy(100,80,"RESULT  $$$");
    outtextxy(330,80,"PROCESSOR");
    outtextxy(160,160,"DEVELOPED BY");
      }
     for(int k=470;k>330;k-=10)
      {
    setcolor(k);
    outtextxy(j,200,"Vishal");
    outtextxy(k,200,"sethia");
    delay(100);
    cleardevice();
    setbkcolor(CYAN);
    settextstyle(4,0,4);
    outtextxy(100,80,"RESULT  $$$");
    outtextxy(330,80,"PROCESSOR");
    outtextxy(160,160,"DEVELOPED BY");
      }
     for(int h=0;h<12;h+=3)
      {
    setcolor(h);
    settextstyle(4,0,4);
    outtextxy(100,80,"RESULT  $$$");
    outtextxy(330,80,"PROCESSOR");
    outtextxy(160,160,"DEVELOPED BY");
    outtextxy(j,200,"Vishal");
    outtextxy(k,200,"sethia");
   //    outtextxy(((j+50+k)/2),200,"&");
    delay(100);
      }
     settextstyle(7,0,1);
     outtextxy(180,300,"Special    Thanks    To");
     outtextxy(195,330,"MISS JEYA PRINCE");
     setlinestyle(DOTTED_LINE,1,1);
     for(h=180;h<420;h+=20)
    {
    line(180,360,h,360);
    delay(200);
    }
    delay(1000);
    cleardevice();
     while(1)
      {
      cleardevice();
      setbkcolor(3);
      setcolor(WHITE);
      setlinestyle(DOTTED_LINE,1,1);
      rectangle(0,0,getmaxx(),getmaxy());
      settextstyle(3,0,1);
      outtextxy(190,35,"RESULT      PROCESSOR");
      rectangle(190,80,410,270);
      outtextxy(200,90,"1.Display");
      outtextxy(200,110,"2.Add records");
      outtextxy(200,130,"3.Report card");
      outtextxy(200,150,"4.Toppers detaiLs");
      outtextxy(200,170,"5.Failure details");
      outtextxy(200,190,"6.Rank List");
      outtextxy(200,210,"7.Exit");
      outtextxy(200,230,"Enter ur option");
      settextstyle(4,0,1);
      line(380,257,395,257);
      gotoxy(49,16);
      cin>>op;
    switch(op)
     {
    case 1: s.reading();
        break;
    case 2: s.writing();
        break;
    case 3: cleardevice();
        setlinestyle(DOTTED_LINE,1,1);
        settextstyle(7,0,1);
        outtextxy(250,35,"REPORT CARD");
        rectangle(190,80,460,270);
        outtextxy(220,120,"Enter the class:");
        gotoxy(47,9);
        cin>>cs;
        outtextxy(220,169,"Enter the roll number:");
        gotoxy(56,12);
        cin>>rol;
        s.copy(cs);
        break;
    case 4: cleardevice();
        setlinestyle(DOTTED_LINE,1,1);
        settextstyle(4,0,2);
        outtextxy(250,35,"TOPPERS DETAILS");
        rectangle( 190,80,450,270);
        outtextxy(220,120,"Enter the class:");
        gotoxy(47,9);
        cin>>cs;
        s.copy(cs);
        break;
    case 5: cleardevice();
        setlinestyle(DOTTED_LINE,1,1);
        settextstyle(4,0,2);
        outtextxy(250,35,"FAILURES DETAILS");
        rectangle(190,80,450,270);
        outtextxy(220,120,"Enter the class:");
        gotoxy(47,9);
        cin>>cs;
        s.copy(cs);
        break;
    case 6: cleardevice();
        setlinestyle(DOTTED_LINE,1,1);
        settextstyle(4,0,2);
        outtextxy(250,35,"RANK LIST");
        rectangle(190,80,450,270);
        outtextxy(220,120,"Enter the class:");
        gotoxy(47,9);
        cin>>cs;
        s.copy(cs);
        break;
    case 7:   than();
        exit(0);
    default:cleardevice();
        outtextxy(150,150,"Invalid Option");
        delay(1000);
    }
    }
    }

Conclusion

This computer project for class 12 student  contains some functions from graphics.h and conio.h, which most of the time not discussed in the class room. So if you have any difficulty using this project, do not hesitate to contact me through email.

Cheers for your success. ;)