• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
projectsgeek

ProjectsGeek

Download Mini projects with Source Code, Java projects with Source Codes

  • Home
  • Java Projects
  • C++ Projects
  • VB Projects
  • PHP projects
  • .Net Projects
  • NodeJs Projects
  • Android Projects
    • Project Ideas
      • Final Year Project Ideas
      • JSP Projects
  • Assignment Codes
    • Fundamentals of Programming Language
    • Software Design Laboratory
    • Data Structure and Files Lab
    • Computer Graphics Lab
    • Object Oriented Programming Lab
    • Assembly Codes
  • School Projects
  • Forum

Computer Graphics

Computer graphics codes in C++ Language

December 6, 2013 by ProjectsGeek 2 Comments

Computer graphics codes in C++ Language

 

These Computer graphics codes are the part of Computer Graphics and Object-oriented programming Lab of Computer Science Engineering and Information technology Subject. You can Download Computer graphics codes from these below links.

Computer graphics codes

Boundary-fill and flood-fill algorithms Code Boundary & Flood Fill Algorithms
Transformations computer graphics Transformations computer graphics
DDA and Bresenham line drawing algorithm Bressenham & DDA Line Drawing algorithms
Computer Graphics Editor Graphics Editor

 

Computer graphics codes Lab Syllabus

2D and 3D Transformations in Computer Graphics

2D Geometric Transformations, Basic transformations- translation,3D transformation Polygon filling methods, shearing, matrix representation and homogeneous coordinate system, Composite transformation, scaling, rotation, other transformations such as reflection.

Color models & animation in Computer Graphics

Animation sequences ,functions & Languages, RGB, YIQ, CMY, HSV,Color Mixing. Key-frame systems, Motion Specifications.

Ray Tracing

Ray tracing methods,Local Illumination and shading.Transformation,algorithms, ray surface intersection calculations Hierarchy.

3D object representation and 3D Viewing in Computer Graphics

Projections, Examples of 3D viewing .curved lines & surfaces, quadratic surfaces, Spline, Polygon surfaces, polygon tables, plane equation, polygon meshes, representation, Specifying an arbitrary 3D View.

Advanced Topics

Rendering equation and Monte Carlo methods, GPU, Bezier curves. Interactive Graphics & usage of at least two tools of computer graphics, , anti-aliasing, texture mapping, shadows,Fractals, fractal lines and surfaces

Basic Concepts of Computer Graphics

Introduction to computer graphics, Basics of Graphics systems, algorithms and display file interpreter,Stroke Principle, Starburst Principle, Bit map method, display of frame buffer. Raster scan and random scan displays, display processor.Scan conversions, lines, line segments, vectors, pixels and frame buffers, vector generation, DDA and Bresenham’s line and circle drawing algorithms.

 

Other Projects to Try:

  1. Bressenham and DDA Line Drawing algorithms
  2. Transformations computer graphics using C++ Language
  3. Create a simple Paintbrush application using various GDI components.
  4. Boundary and Flood Fill Algorithms in C++ Language
  5. Graphics Editor code Using C++ Language

Filed Under: Computer Graphics

Bitwise Operations using C++

September 7, 2011 by ProjectsGeek Leave a Comment

Bit-wise Operations using C++
#include
#include
#include void dectobi(int p)
{
int b,i,x,d;
for(i=31;i>=0;i--)
{
d=1<<i;
b=p&d;
if(b==0)
printf("0");
else
printf("1");
}
} 

void main()
{

int i,j,k,ch,n,m,a;
char cho;
clrscr();
do
{
printf("enter a integer\n");
scanf("%d",&n);
dectobi(n);
printf("\n 1 for 1`s compliment");
printf("\n 2 for AND opertion");
printf("\n 3 for OR opertion");
printf("\n 4 for EX-OR opertion");
printf("\n 5 for LEFT SHIFT opertion");
printf("\n 6 for RIGHT SHIFT opertion");
printf("\n 7 for EXIT\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf(" \n1`s compliment\n");
a=~n;
dectobi(a);
break;
case 2:
printf("enter intger\n");
scanf("%d",&m);
dectobi(m);
printf("after and\n");
a=n&m;
dectobi(a);
break;
case 3:
printf("enter intger\n");
scanf("%d",&m);
dectobi(m);
printf("after OR\n");
a=n|m;
dectobi(a);
break;
case 4:
printf("enter intger\n");
scanf("%d",&m);
dectobi(m);
printf("after EX-OR\n");
a=n^m ;
dectobi(a);
break;
case 5:
printf("enter the no by u want to LEFT SHIFT");
scanf("%d",&m);
a=n<<m;
printf("after LEFT SHIFT\n");
a=n<<1;
        dectobi(a);
break;
case 6:
printf("enter the no by u want to RIGHT SHIFT");
scanf("%d",&m);
a=n>>m;
printf("after RIGHT SHIFT\n");
dectobi(a);
break;
case 7:
exit(0);
}
flushall();
printf("\nwant to continue (y/n)");
scanf("%c",&cho);
}
while(cho!='n');

}

Other Projects to Try:

  1. Operations on matrices like addition, multiplication, saddle point, magic square ,inverse & transpose
  2. Matrix Operations in C Language
  3. Set operations – Union, Intersection, Difference, Symmetric Difference using C
  4. How to Implement Hash Table using C language
  5. Sparse Matrix Operations Code using C Langauge

Filed Under: Computer Graphics Tagged With: Computer Graphics

Friend Function Implementation using C++

September 7, 2011 by ProjectsGeek Leave a Comment

Friend Function Implementation using C++
#include
#include #include
#include
#include
int i=0;
int idno;
class student
{
public:
friend void issue ();
friend void  ret ();
};
class lib
{
char name[10];
int roll; 

public:

int status;
lib();
void idinfor();
friend void issue ();
friend void  ret ();
};
lib::lib()
{
status=0;
}
void lib::idinfor()
{
i++;
cout<<“\n\n\t\t ENTER UR NAME…”;
gets(name);
cout<<“\n\n\t\t ENTER UR ROLL NO…”;
cin>>roll;
cout<<“\n\n\t\t UR ID NUMBER IS….”<<i+1998;< p=””>

}
void issue(int status)
{

int bn;
cout<<“\n\n\t\t LIST OF AVAILABLE BOOKS FOR U”;
cout<<“\n\n\t\t PRESS 1 BALA\n\t\t PRESS 2 VENU\n\t\t PRESS 3 OOPS\n\t\t PRESS 4 MAT”;
cout<<“\n\n\t\t ENTER UR CHOICE”;
cin>>bn;

if(status<3)
    {
cout<<“\n\n\t\t BOOK IS AVAILABLE FOR U”;
}
else
{
cout<<“\n\n\t\t BOOK IS NOT AVAILABLE FOR U”;
cout<<“\n\n\t\t U CANT ISSUE MORE THAN TWO BOOKS”;
}
}
void ret()
{
cout<<“\n\n\t\t THANK YOU”;
}
void main()
{
lib l[10];
int ch;
clrscr();
do
{
cout<<“\n\t\t PRESS 1 FOR UR ID NUMBER INFORMATION”;
cout<<“\n\t\t PRESS 2 FOR ISSUE A NEW BOOK “;
cout<<“\n\t\t PREES 3 FOR RETURN A BOOK “;
cout<<“\n\t\t PRESS 4 FOR EXIT”;
cout<<“\n\t\t ENTER UR CHOICE…”;
cin>>ch;
switch(ch)
{
case 1:
clrscr();
l[i].idinfor();
break;
case 2:
clrscr();
cout<<“\n\n\t\tENTER UR ID NO…”;
cin>>idno;
issue(l[i].status);
l[i].status++;
break;
case 3:
clrscr();
cout<<“\n\n\t\tENTER UR ID NO…”;
cin>>idno;
ret();
l[i].status–;
break;
case 4:
exit(0);
break;
}
}while(ch!=4);
}

Other Projects to Try:

  1. Matrix Operations in C Language
  2. Weather report program in c++ using constructor
  3. Operator Overloading on String Functions C++ Language
  4. Student Database in C Language
  5. How to Implement Hash Table using C language

Filed Under: Computer Graphics Tagged With: Computer Graphics

Cricket Database project using C++

September 5, 2011 by ProjectsGeek Leave a Comment

Cricket Database project using C++

 
 
Cricket Database project using C++ is advanced level project which makes use of object oriented concepts for implementing this cricket database project. It shows all kinds of stats from the game such as country, matches, bowling,innings, runs, ball played, fifties, hundreds, wickets, best batting performances, best bowling performances. You can input data for last match using menu provided in this application, after that program will guide user to provide other input data.
 

Cricket Database project Source Code

 
#include
#include
#include
#include
#include
#include #include
#include
#include
/*------------------base class------------------------------*/
class player
{
float strate,btavg,blavg;
int runs,wic,hiscr,bbol,overs,balls,innings,r1,w1,o1,b1,hcen,cen,i1;
public:
int mat;
char name[10];
char country[10];
player();
void getdata();
void update();
void showdata();
void calculation();
void search();
void modify();
void updatetest();
void menu();
};
/*----------------------constructor------------------------------*/
player::player()
{
strcpy(name," ");
strcpy(country," ");
strate=0;
btavg=0;
innings=0;
balls=0;
overs=0;
blavg=0;
runs=0;
wic=0;
mat=0;
hiscr=0;
bbol=0;
cen=0;
hcen=0;
}
/* -----------------------------fun for calculation -----------*/
void player::calculation()
{
strate=(float)(runs/balls)*100;
btavg=(float)runs/innings;
blavg=(float)overs/wic;
}
/*---------------------- scan data from user -----------------*/
void player::getdata()
{
cleardevice();
settextstyle(1,0,1);
outtextxy(100,50," ENTER DATA ");
settextstyle(0,0,1); 

 

//cout<<"\n\t\t ENTER INFORMATION: \n\n";
cout<<"\n\n\n\t\t Name: ";
gets(name);
cout<<"\n\t\t Country: ";
gets(country);
cout<<"\n\t\t Matches: ";
cin>>mat;
cout<<"\n\t\t Innings: ";
cin>>innings;
cout<<"\n\t\t Runs: ";
cin>>runs;
cout<<"\n\t\t Balls Played: ";
cin>>balls;
cout<<"\n\t\t Fifties: ";
cin>>hcen;
cout<<"\n\t\t Hundreds: ";
cin>>cen;
cout<<"\n\t\t Overs Bowled: ";
cin>>overs;
cout<<"\n\t\t Wickets: ";
cin>>wic;
cout<<"\n\t\t Best Batting Performance: ";
cin>>hiscr;
cout<<"\n\t\t Best Bowling Performance: ";
cin>>bbol;

}
/*-------------- fun used for modification -----------------*/
void player::update()
{
//cout<<"\n\n\t\t ENTER DATA OF LAST MATCH\n";
cleardevice();
settextstyle(1,0,1);
outtextxy(100,50," ENTER DATA OF LAST MATCH");
settextstyle(0,0,1);
cout<<"\n\n\n\t\t Runs: ";
cin>>r1;
if(r1>100)
cen++;
if(r1>50&&r1<100)
        hcen++;
runs+=r1;
cout<<"\n\t\t Wickets: ";
cin>>w1;
wic+=w1;
mat++;
cout<<"\n\t\t OUT/NOTOUT(y/n): ";
char ch=getche();
if(ch=='y')
innings++;
cout<<"\n\t\t Overs Bowled :";
cin>>o1;
overs+=o1;
cout<<"\n\t\t Balls Played";
cin>>b1;
balls+=b1;
if(hiscr<r1)
hiscr=r1;
if(bbol<w1)
bbol=w1;
}
/*--------------------- fun for displaying the data --------------*/
void player::showdata()
{
int x=50;
char str[20];
cleardevice();
rectangle(50,150,610,250);
line(50,200,610,200);
for(int i=0;i<6;i++)
    {
x+=80;
line(x,150,x,250);
}
outtextxy( 60,170,"MATCHS");
outtextxy(140,170,"RUNS");
outtextxy(220,170,"WICKETS");
outtextxy(300,170,"AVG(BAT)");
outtextxy(380,170,"AVG(BOL)");
outtextxy(460,170,"100`s");
outtextxy(540,170,"50`s");
outtextxy( 50,280,"BEST PERFORMANCE IN A MATCH ::");
outtextxy( 50,300,"RUNS : ");
outtextxy( 50,320,"WICKETS :");
sprintf(str,"%d",mat);
outtextxy(60,220,str);
sprintf(str,"%d",runs);
outtextxy(140,220,str);
sprintf(str,"%d",wic);
outtextxy(220,220,str);
sprintf(str,"%f",btavg);
outtextxy(300,220,str);
sprintf(str,"%f",blavg);
outtextxy(380,220,str);
sprintf(str,"%d",cen);
outtextxy(460,220,str);
sprintf(str,"%d",hcen);
outtextxy(540,220,str);
settextstyle(1,0,1);
sprintf(str,"%s",country);
outtextxy(50,110,str);
sprintf(str,"%s",name);
outtextxy(50,90,str);
settextstyle(0,0,1);
sprintf(str,"%d",hiscr);
outtextxy(130,300,str);
sprintf(str,"%d",bbol);
outtextxy(130,320,str);
getch();
}
fstream file,file1,tfile,tfile1;
int ch1;
/*----------------------------- main -------------*/
void main()
{
player p;
clrscr();
int ch,i=0,gm,gd=DETECT;
char st[10];
int x,y;
x=100;
y=100;

initgraph(&gd,&gm,"g:\\tc\\bgi");
char pname[10],cname[10],password[10]="",c;
setbkcolor(BLUE);
while(!kbhit())
{

settextstyle(1,0,6);
outtextxy(150,200,"CRICKETER`S");
outtextxy(170,270,"DATABASE");
}
settextstyle(0,0,1);
cleardevice();
setcolor(11);
settextstyle(1,0,1);
outtextxy(100,380,"LOADING...");

for(i=0;i<401;i++)
    {
outtextxy(100+i,400,"#");
if(i<400&&i>370)
delay(40);
delay(10);
}
settextstyle(0,0,1);
cleardevice();
getch();
//cleardevice();
/*------------------ starting menu -------*/
int tag;
tag:
cleardevice();
settextstyle(1,0,2);
outtextxy(200,100," 1 :: ONE DAY") ;
outtextxy(200,130,"     2 :: TEST") ;
//cin>>ch1;

ch1=getche();
ch1=ch1-'0';
settextstyle(0,0,1);
if(ch1==1)
{
do
{
cleardevice();
//p.menu();
settextstyle(1,0,2);
outtextxy(200,100," 1 :: ADD RECORDS ") ;
outtextxy(200,130," 2 :: MODIFY RECORDS ") ;
outtextxy(200,160," 3 :: SEARCH RECORD (NAME)") ;
outtextxy(200,190," 4 :: SEARCH RECORD (COUNTRY)") ;
outtextxy(200,220," 5 :: LIST OF PLAYER OF ONE COUNTRY") ;
outtextxy(200,250," 6 :: BACK") ;
outtextxy(200,280," 7 :: EXIT") ;
//cin>>ch;
ch=getche();
ch=ch-'0';

settextstyle(0,0,1);

switch(ch)
{
/*----- ODI insert --------------*/
case 1:

cleardevice();
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file.seekp(0,ios::end);
p.getdata();
p.calculation();
file.write((char*)&p,sizeof(p));
file.clear();
file.close();
c=getch();
break;
/*------- ODI name wise search -----------*/

case 3:

cleardevice();
cout<<"\n\t\t Name For Search: ";
gets(pname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
//if(i>250&&i<300)
                      //    delay(40);

delay(10);
}
cleardevice();
int flag=0;
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file.seekp(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.name,pname))
{
flag=1;
cout<<"\n\n";
p.showdata();
break;
}
}
file.clear();
file.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
//cout<<"\n\n\t\t Enter Any Key To Cont.";
//cin>>c;
c=getch();
break;

/*--------------  ODI modification --------------*/
case 2:

cleardevice();
cout<<"\n\t\tENTER PASSWORD  ";
int i=0;
while(i<6)
                {
password[i]=getche();
cout<<"*";
i++;
}
getch();
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();

if(!strcmp("vineet",password))
{
cout<<"\n\t\t Name For Modification ";
gets(pname);
flag=0;
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file1.open("temp1.txt",ios::in|ios::out|ios::ate);
if(!tfile1)
cout<<"\nerror";
file1.seekp(0,ios::beg);
file.seekp(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
{

if(!strcmp(p.name,pname))
{
flag=1;
p.update();
p.calculation();
file1.write((char*)&p,sizeof(p));
}
else
{
tfile1.write((char*)&p,sizeof(p));
}
}
file.clear();
file.close();
file1.clear();
file1.close();
if(flag==1)
{
remove("ODI.txt");
rename("temp1.txt","ODI.txt");

}
if(flag==0)
cout<<"\n\t\t Record Not Found";
}
else
cout<<"\n\t\t Wrong Password";
c=getch();
break;

/*------------ ODI country wise search ------*/
case 4:
cleardevice();
cout<<"\n\t\t Country`s Name For Search: ";
gets(cname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
//if(i>333&&i<400)
                      //    delay(40);
}
cleardevice();
flag=0;
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file.seekp(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.country,cname))
{
flag=1;
cout<<"\n\n";
p.showdata();
}
}
file.clear();
file.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
//cout<<"\n\n\t\t Enter Any Key To Cont.";
//cin>>c;
c=getch();
break;
/*------ ODI list of players -----------*/
case 5:
cleardevice();
cout<<"\n\t\t Country`s Name For Search: ";
gets(cname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
}
cleardevice();
flag=0;
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file.seekp(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.country,cname))
{
flag=1;
settextstyle(1,0,1);
//cout<<"\n\n\t\t"< <p.name;

sprintf(st,"%s",p.name);
outtextxy(x,y,st);
y=y+30;
settextstyle(0,0,1);
}
}
file.clear();
file.close();
if(flag==0)
cout<<"\n\t\t Record Not Found"; 

//cout<<"\n\n\t\t Enter Any Key To Cont.";
//cin>>c;
c=getch();
break;
case 6:
goto tag;
//break;

case 7:
exit(0);
break;
}
}while(1);
}
if(ch1==2)
{
do
{
cleardevice();
//p.menu();
settextstyle(1,0,2);
outtextxy(200,100," 1 :: ADD RECORDS ") ;
outtextxy(200,130," 2 :: MODIFY RECORDS ") ;
outtextxy(200,160," 3 :: SEARCH RECORD (NAME)") ;
outtextxy(200,190," 4 :: SEARCH RECORD (COUNTRY)") ;
outtextxy(200,220," 5 :: LIST OF PLAYER OF ONE COUNTRY") ;
outtextxy(200,250," 6 :: BACK") ;
outtextxy(200,280," 7 :: EXIT") ;
//cin>>ch;
ch=getche();
ch=ch-'0';

settextstyle(0,0,1);

switch(ch)
{
/*------------------ TEST insert ------------------*/
case 1:
cleardevice();
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile.seekp(0,ios::end);
p.getdata();
p.calculation();
tfile.write((char*)&p,sizeof(p));
tfile.clear();
tfile.close();
break;
/*------------------ TEST name wise search ------------------*/
case 3:
cleardevice();
cout<<"\n\t\t Name For Search: ";
gets(pname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();
int flag=0;
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile.seekp(0,ios::beg);
while(tfile.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.name,pname))
{
flag=1;
cout<<"\n\n";
p.showdata();
break;
}
}
tfile.clear();
tfile.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
c=getch();
break;
/*------------------ TEST modification ------------------*/
case 2:
cleardevice();
cout<<"\n\t\tENTER PASSWORD";
int i=0;
while(i<6)
                {
password[i]=getche();
cout<<"*";
i++;
}
getch();
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();

if(!strcmp("vineet",password))
{
cout<<"\n\t\t Name For Modification ";
gets(pname);
flag=0;
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile1.open("temp1.txt",ios::in|ios::out|ios::ate);
if(!tfile1)
cout<<"\nerror";
tfile1.seekp(0,ios::beg);
tfile.seekp(0,ios::beg);
while(tfile.read((char*)&p,sizeof(p)))
{

if(!strcmp(p.name,pname))
{
flag=1;
cout<<"\n\t\t Enter Data For First Inning: ";
p.update();
cout<<"\n\t\t Enter Data For Second Inning: ";
p.update();
p.mat--;
p.calculation();
tfile1.write((char*)&p,sizeof(p));
}
else
{
tfile1.write((char*)&p,sizeof(p));
}
}
tfile.clear();
tfile.close();
tfile1.clear();
tfile1.close();
if(flag==1)
{
remove("TEST.txt");
rename("temp1.txt","TEST.txt");

}
if(flag==0)
cout<<"\n\t\t Record Not Found";
}
else
cout<<"\n\t\t Wrong Password";
c=getch();
break;
/*------------------ TEST country wise search ------------------*/
case 4:
cleardevice();
cout<<"\n\t\t Country`s Name For Search: ";
gets(cname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();
flag=0;
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile.seekp(0,ios::beg);
while(tfile.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.country,cname))
{
flag=1;
cout<<"\n\n";
p.showdata();
}
}
tfile.clear();
tfile.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
break;
/*------------------ TEST list ------------------*/
case 5:
cleardevice();
cout<<"\n\t\t Country`s Name For Search: ";
gets(cname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();
flag=0;
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile.seekp(0,ios::beg);
while(tfile.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.country,cname))
{
flag=1;
settextstyle(1,0,1);
//cout<<"\n\n\t\t"< <p.name;

sprintf(st,"%s",p.name);
outtextxy(x,y,st);
y=y+30;
settextstyle(0,0,1);
//cout<<"\n\n\t\t"< <p.name;
 

}
}
file.clear();
file.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
//char c;
//cout<<"\n\n\t\t Enter Any Key To Cont.";
//cin>>c;
c=getch();
break;
case 6:
goto tag;
case 7:
exit(0);
break;
}
}while(1);
}
}
/* ------------------------------end of main -----------------*/ 

#include
#include
#include
#include
#include
#include #include
#include
#include
/*------------------base class--------------------------------*/
class player
{
float strate,btavg,blavg;
int runs,wic,hiscr,bbol,overs,balls,innings,r1,w1,o1,b1,hcen,cen,i1;
public:
int mat;
char name[10];
char country[10];
player();
void getdata();
void update();
void showdata();
void calculation();
void search();
void modify();
void updatetest();
void menu();
};
/*----------------------constructor-------------------------------------*/
player::player()
{
strcpy(name," ");
strcpy(country," ");
strate=0;
btavg=0;
innings=0;
balls=0;
overs=0;
blavg=0;
runs=0;
wic=0;
mat=0;
hiscr=0;
bbol=0;
cen=0;
hcen=0;
}
/* -----------------------------fun for calculation ----------------------*/
void player::calculation()
{
strate=(float)(runs/balls)*100;
btavg=(float)runs/innings;
blavg=(float)overs/wic;
}
/*---------------------- scan data from user -------------------------*/
void player::getdata()
{
cleardevice();
settextstyle(1,0,1);
outtextxy(100,50," ENTER DATA ");
settextstyle(0,0,1);

//cout<<"\n\t\t ENTER INFORMATION: \n\n";
cout<<"\n\n\n\t\t Name: ";
gets(name);
cout<<"\n\t\t Country: ";
gets(country);
cout<<"\n\t\t Matches: ";
cin>>mat;
cout<<"\n\t\t Innings: ";
cin>>innings;
cout<<"\n\t\t Runs: ";
cin>>runs;
cout<<"\n\t\t Balls Played: ";
cin>>balls;
cout<<"\n\t\t Fifties: ";
cin>>hcen;
cout<<"\n\t\t Hundreds: ";
cin>>cen;
cout<<"\n\t\t Overs Bowled: ";
cin>>overs;
cout<<"\n\t\t Wickets: ";
cin>>wic;
cout<<"\n\t\t Best Batting Performance: ";
cin>>hiscr;
cout<<"\n\t\t Best Bowling Performance: ";
cin>>bbol;

}
/*------------------------------ fun used for modification -----------------*/
void player::update()
{
//cout<<"\n\n\t\t ENTER DATA OF LAST MATCH\n";
cleardevice();
settextstyle(1,0,1);
outtextxy(100,50," ENTER DATA OF LAST MATCH");
settextstyle(0,0,1);
cout<<"\n\n\n\t\t Runs: ";
cin>>r1;
if(r1>100)
cen++;
if(r1>50&&r1<100)
        hcen++;
runs+=r1;
cout<<"\n\t\t Wickets: ";
cin>>w1;
wic+=w1;
mat++;
cout<<"\n\t\t OUT/NOTOUT(y/n): ";
char ch=getche();
if(ch=='y')
innings++;
cout<<"\n\t\t Overs Bowled :";
cin>>o1;
overs+=o1;
cout<<"\n\t\t Balls Played";
cin>>b1;
balls+=b1;
if(hiscr<r1)
hiscr=r1;
if(bbol<w1)
bbol=w1;
}
/*------------------------------------- fun for displaying the data -------------*/
void player::showdata()
{
int x=50;
char str[20];
cleardevice();
rectangle(50,150,610,250);
line(50,200,610,200);
for(int i=0;i<6;i++)
    {
x+=80;
line(x,150,x,250);
}
outtextxy( 60,170,"MATCHS");
outtextxy(140,170,"RUNS");
outtextxy(220,170,"WICKETS");
outtextxy(300,170,"AVG(BAT)");
outtextxy(380,170,"AVG(BOL)");
outtextxy(460,170,"100`s");
outtextxy(540,170,"50`s");
outtextxy( 50,280,"BEST PERFORMANCE IN A MATCH ::");
outtextxy( 50,300,"RUNS : ");
outtextxy( 50,320,"WICKETS :");
sprintf(str,"%d",mat);
outtextxy(60,220,str);
sprintf(str,"%d",runs);
outtextxy(140,220,str);
sprintf(str,"%d",wic);
outtextxy(220,220,str);
sprintf(str,"%f",btavg);
outtextxy(300,220,str);
sprintf(str,"%f",blavg);
outtextxy(380,220,str);
sprintf(str,"%d",cen);
outtextxy(460,220,str);
sprintf(str,"%d",hcen);
outtextxy(540,220,str);
settextstyle(1,0,1);
sprintf(str,"%s",country);
outtextxy(50,110,str);
sprintf(str,"%s",name);
outtextxy(50,90,str);
settextstyle(0,0,1);
sprintf(str,"%d",hiscr);
outtextxy(130,300,str);
sprintf(str,"%d",bbol);
outtextxy(130,320,str);
getch();
}
fstream file,file1,tfile,tfile1;
int ch1;
/*----------------------------- main ---------------------*/
void main()
{
player p;
clrscr();
int ch,i=0,gm,gd=DETECT;
char st[10];
int x,y;
x=100;
y=100;

initgraph(&gd,&gm,"g:\\tc\\bgi");
char pname[10],cname[10],password[10]="",c;
setbkcolor(BLUE);
while(!kbhit())
{

settextstyle(1,0,6);
outtextxy(150,200,"CRICKETER`S");
outtextxy(170,270,"DATABASE");
}
settextstyle(0,0,1);
cleardevice();
setcolor(11);
settextstyle(1,0,1);
outtextxy(100,380,"LOADING...");

for(i=0;i<401;i++)
    {
outtextxy(100+i,400,"#");
if(i<400&&i>370)
delay(40);
delay(10);
}
settextstyle(0,0,1);
cleardevice();
getch();
//cleardevice();
/*------------------ starting menu -------*/
int tag;
tag:
cleardevice();
settextstyle(1,0,2);
outtextxy(200,100," 1 :: ONE DAY") ;
outtextxy(200,130,"     2 :: TEST") ;
//cin>>ch1;

ch1=getche();
ch1=ch1-'0';
settextstyle(0,0,1);
if(ch1==1)
{
do
{
cleardevice();
//p.menu();
settextstyle(1,0,2);
outtextxy(200,100," 1 :: ADD RECORDS ") ;
outtextxy(200,130," 2 :: MODIFY RECORDS ") ;
outtextxy(200,160," 3 :: SEARCH RECORD (NAME)") ;
outtextxy(200,190," 4 :: SEARCH RECORD (COUNTRY)") ;
outtextxy(200,220," 5 :: LIST OF PLAYER OF ONE COUNTRY") ;
outtextxy(200,250," 6 :: BACK") ;
outtextxy(200,280," 7 :: EXIT") ;
//cin>>ch;
ch=getche();
ch=ch-'0';

settextstyle(0,0,1);

switch(ch)
{
/*----- ODI insert ----------*/
case 1:

cleardevice();
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file.seekp(0,ios::end);
p.getdata();
p.calculation();
file.write((char*)&p,sizeof(p));
file.clear();
file.close();
c=getch();
break;
/*------- ODI name wise search -------------*/

case 3:

cleardevice();
cout<<"\n\t\t Name For Search: ";
gets(pname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
//if(i>250&&i<300)
                      //    delay(40);

delay(10);
}
cleardevice();
int flag=0;
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file.seekp(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.name,pname))
{
flag=1;
cout<<"\n\n";
p.showdata();
break;
}
}
file.clear();
file.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
//cout<<"\n\n\t\t Enter Any Key To Cont.";
//cin>>c;
c=getch();
break;

/*--------------  ODI modification --------------*/
case 2:

cleardevice();
cout<<"\n\t\tENTER PASSWORD  ";
int i=0;
while(i<6)
                {
password[i]=getche();
cout<<"*";
i++;
}
getch();
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();

if(!strcmp("vineet",password))
{
cout<<"\n\t\t Name For Modification ";
gets(pname);
flag=0;
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file1.open("temp1.txt",ios::in|ios::out|ios::ate);
if(!tfile1)
cout<<"\nerror";
file1.seekp(0,ios::beg);
file.seekp(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
{

if(!strcmp(p.name,pname))
{
flag=1;
p.update();
p.calculation();
file1.write((char*)&p,sizeof(p));
}
else
{
tfile1.write((char*)&p,sizeof(p));
}
}
file.clear();
file.close();
file1.clear();
file1.close();
if(flag==1)
{
remove("ODI.txt");
rename("temp1.txt","ODI.txt");

}
if(flag==0)
cout<<"\n\t\t Record Not Found";
}
else
cout<<"\n\t\t Wrong Password";
c=getch();
break;

/*------------ ODI country wise search --------------*/
case 4:
cleardevice();
cout<<"\n\t\t Country`s Name For Search: ";
gets(cname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
//if(i>333&&i<400)
                      //    delay(40);
}
cleardevice();
flag=0;
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file.seekp(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.country,cname))
{
flag=1;
cout<<"\n\n";
p.showdata();
}
}
file.clear();
file.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
//cout<<"\n\n\t\t Enter Any Key To Cont.";
//cin>>c;
c=getch();
break;
/*------ ODI list of players ------------*/
case 5:
cleardevice();
cout<<"\n\t\t Country`s Name For Search: ";
gets(cname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
}
cleardevice();
flag=0;
file.open("ODI.txt",ios::in|ios::out|ios::ate);
file.seekp(0,ios::beg);
while(file.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.country,cname))
{
flag=1;
settextstyle(1,0,1);
//cout<<"\n\n\t\t"< <p.name;

sprintf(st,"%s",p.name);
outtextxy(x,y,st);
y=y+30;
settextstyle(0,0,1);
}
}
file.clear();
file.close();
if(flag==0)
cout<<"\n\t\t Record Not Found"; 

//cout<<"\n\n\t\t Enter Any Key To Cont.";
//cin>>c;
c=getch();
break;
case 6:
goto tag;
//break;

case 7:
exit(0);
break;
}
}while(1);
}
if(ch1==2)
{
do
{
cleardevice();
//p.menu();
settextstyle(1,0,2);
outtextxy(200,100," 1 :: ADD RECORDS ") ;
outtextxy(200,130," 2 :: MODIFY RECORDS ") ;
outtextxy(200,160," 3 :: SEARCH RECORD (NAME)") ;
outtextxy(200,190," 4 :: SEARCH RECORD (COUNTRY)") ;
outtextxy(200,220," 5 :: LIST OF PLAYER OF ONE COUNTRY") ;
outtextxy(200,250," 6 :: BACK") ;
outtextxy(200,280," 7 :: EXIT") ;
//cin>>ch;
ch=getche();
ch=ch-'0';

settextstyle(0,0,1);

switch(ch)
{
/*------------------ TEST insert ------------------*/
case 1:
cleardevice();
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile.seekp(0,ios::end);
p.getdata();
p.calculation();
tfile.write((char*)&p,sizeof(p));
tfile.clear();
tfile.close();
break;
/*------------------ TEST name wise search ------------------*/
case 3:
cleardevice();
cout<<"\n\t\t Name For Search: ";
gets(pname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();
int flag=0;
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile.seekp(0,ios::beg);
while(tfile.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.name,pname))
{
flag=1;
cout<<"\n\n";
p.showdata();
break;
}
}
tfile.clear();
tfile.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
c=getch();
break;
/*------------------ TEST modification ------------*/
case 2:
cleardevice();
cout<<"\n\t\tENTER PASSWORD";
int i=0;
while(i<6)
                {
password[i]=getche();
cout<<"*";
i++;
}
getch();
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();

if(!strcmp("vineet",password))
{
cout<<"\n\t\t Name For Modification ";
gets(pname);
flag=0;
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile1.open("temp1.txt",ios::in|ios::out|ios::ate);
if(!tfile1)
cout<<"\nerror";
tfile1.seekp(0,ios::beg);
tfile.seekp(0,ios::beg);
while(tfile.read((char*)&p,sizeof(p)))
{

if(!strcmp(p.name,pname))
{
flag=1;
cout<<"\n\t\t Enter Data For First Inning: ";
p.update();
cout<<"\n\t\t Enter Data For Second Inning: ";
p.update();
p.mat--;
p.calculation();
tfile1.write((char*)&p,sizeof(p));
}
else
{
tfile1.write((char*)&p,sizeof(p));
}
}
tfile.clear();
tfile.close();
tfile1.clear();
tfile1.close();
if(flag==1)
{
remove("TEST.txt");
rename("temp1.txt","TEST.txt");

}
if(flag==0)
cout<<"\n\t\t Record Not Found";
}
else
cout<<"\n\t\t Wrong Password";
c=getch();
break;
/*------------------ TEST country wise search -------*/
case 4:
cleardevice();
cout<<"\n\t\t Country`s Name For Search: ";
gets(cname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();
flag=0;
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile.seekp(0,ios::beg);
while(tfile.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.country,cname))
{
flag=1;
cout<<"\n\n";
p.showdata();
}
}
tfile.clear();
tfile.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
break;
/*------------------ TEST list --------*/
case 5:
cleardevice();
cout<<"\n\t\t Country`s Name For Search: ";
gets(cname);
cleardevice();
setcolor(10);
outtextxy(100,380,"LOADING...");
for(i=0;i<401;i++)
                {
outtextxy(100+i,400,"#");
delay(10);
if(i>350&&i<400)
                        delay(40);
}
cleardevice();
flag=0;
tfile.open("TEST.txt",ios::in|ios::out|ios::ate);
tfile.seekp(0,ios::beg);
while(tfile.read((char*)&p,sizeof(p)))
{
if(!strcmp(p.country,cname))
{
flag=1;
settextstyle(1,0,1);
//cout<<"\n\n\t\t"< <p.name;

sprintf(st,"%s",p.name);
outtextxy(x,y,st);
y=y+30;
settextstyle(0,0,1);
//cout<<"\n\n\t\t"< <p.name;
 

}
}
file.clear();
file.close();
if(flag==0)
cout<<"\n\t\t Record Not Found";
//char c;
//cout<<"\n\n\t\t Enter Any Key To Cont.";
//cin>>c;
c=getch();
break;
case 6:
goto tag;
case 7:
exit(0);
break;
}
}while(1);
}
}
/* ------------------------------end of main ----------*/ 

Other Projects to Try:

  1. string operations such as Copy, Length, Reversing, Palindrome, Concatenation
  2. Graphics Editor code Using C++ Language
  3. Cricket Database Project
  4. Student Database using Virtual functions in C++
  5. Student Database in C Language

Filed Under: Computer Graphics Tagged With: Computer Graphics

Exception Handling in C++ Language

April 6, 2011 by ProjectsGeek Leave a Comment

Exception Handling in C++ Language

Create a class named Television that has data members to hold the model number and the screen size in inches,and the price for Exception Handling in C++ program.Member functions include overloaded insertion and extraction operators.If more than four digits are entered for the model,if the screen size is smaller than 12 or greater than 70 inches, or if the price is negative or over $5000 then throw an integer.

Write a main() function that instantiates a television object,allows user to enter data and displays the data members .If an exception is caught ,replace all the data member values with zero values .

Exception Handling in C++ Code

#include  
 #include  
 void test(int,int,int);  
 class television  
 {  
   public:  
   int mod_no,price,size;  
   void operator<<(telivision a)  
   {  
     cout<<"\n\t## INPUT ##";  
     cout<<"\n\tENTER THE MODEL NO.:";  
     cin>>mod_no;  
     cout<<"\n\tENTER THE SIZE:";  
     cin>>size;  
     cout<<"\n\tENTER THE PRICE:";  
     cin>>price;  
     test(mod_no,price,size);  
     getch();  
   }  
   void operator>>(television a)  
   {  
     cout<<"\n\t## DISPLAY ##)";  
     cout<<"\nMODEL NO.:"<<mod_no<<"\nsize:"<<size<<"\nprice:"<<price; <br="">     getch();  
   }  
 };  
 void test(int mod_no,int price,int size)  
 {  
   if(mod_no>=10000)  
     throw(1);  
   if(price>5000)  
     throw(2);  
   if(price<0)  
     throw(3);  
   if(size<12)  
     throw(4);  
   if(size>70)  
     throw(5);  
 }  
 void main()  
 {  
   int ch,i;  
   television n,o;  
   do  
   {  
     cout<<"\n\t##### MAIN MENU #####";  
     cout<<"\n\t1.INPUT";  
     cout<<"\n\t2.DISPLAY";  
     cout<<"\n\t3.EXIT";  
     cout<<"\n\tENTER UR CHOICE:";  
     cin>>ch;  
     switch(ch)  
     {  
       case 1:  
         try  
         {  
           n<<o; <br="">         }  
         catch(int i)  
         {  
           if(i==1)  
             cout<<"\nMODEL NO IS NOT CORRECT";  
           else if(i==2)  
             cout<<"\nPRICE IS NOT CORRECT";  
           else if(i==3)  
             cout<<"\nPRICE IS NEGATIVE";  
           else if(i==4)  
             cout<<"\nSIZE IS VERY SMALL";  
           else if(i==5)  
             cout<<"\nSIZE IS VERY LARGE";  
           n.mod_no=0;  
           n.price=0;  
           n.size=0;  
         }  
         getch();  
         break;  
       case 2: n>>o;  
         getch();  
         break;  
       case 3: break;  
     }  
   }while(ch!=3);  
 }

 

Other Projects to Try:

  1. How to Implement Hash Table using C language
  2. Hash table code in C Language
  3. Exception Handling In java
  4. File Handling and IO Handling in Java Programming
  5. Matrix Operations in C Language

Filed Under: C Assignments, Computer Graphics Tagged With: Computer Graphics

Student Database using Virtual functions in C++

April 6, 2011 by ProjectsGeek 1 Comment

Student Database using Virtual functions in C++

Design a base class consisting of the data members such as name of the student,roll number and subject.The derived class consists of the data members subject code,internal assessment and university examination marks.Construct a virtual base class for the item name of the student and roll number.The program should have the facilities.

  • Build a master table
  • List a table
  • Insert a new entry
  • Delete old entry
  • Edit an entry
  •  Search for a record

Student Database using Virtual functions in C++Code

 #include  
 #include  
 #include  
 #include  
 class assessment;  
 class student  
 {  
   char name[20],sub[20];  
   int rno,sub_code,in,uni;  
   public:  
   friend assessment;  
 };  
 class assessment  
 {  
   int internal,uni_marks;  
   public:  
   void menu();  
   void input(student *S);  
   void display(student *S);  
   int rlno(student *S);  
   void del(student *S);  
   void modify(student *S);  
 };  
 void assessment::input(student *S)  
 {  
   cout<<"\nEnter name : ";  
   gets(S->name);  
   cout<<"\nEnter Roll no : ";  
   cin>>S->rno;  
   cout<<"\nEnter subject : ";  
   gets(S->sub);  
   cout<<"\nEnter sub code : ";  
   cin>>S->sub_code;  
   cout<<"\nEnter Internal marks : ";  
   cin>>internal;  
   S->in=internal;  
   cout<<"\nEnter University exam marks : ";  
   cin>>uni_marks;  
   S->uni=uni_marks;  
 }  
 void assessment::display(student *S)  
 {  
   cout<<"\n"<rno;  
   cout<<"\t"<name;  
   cout<<"\t"<sub;  
   cout<<"\t"<sub_code;  
   cout<<"\t"<in;  
   cout<<"\t"<uni;  
 }  
 void assessment::menu()  
 {  
   cout<<"\t\t\t"<<"STUDENT DATABASE MANAGENENT"<<endl<<"\n1.create"<<endl; <br="">   cout<<"2.Display"<<endl<<"3.insert"<<endl; <br="">   cout<<"4.Delete"<<endl<<"5.modify"; <br="">   cout<<endl<<"6.search"<<endl<<"7.exit"; <br=""> }  
 int assessment::rlno(student *S)  
 {  
   return (S->rno);  
 }  
 void assessment ::modify(student *S)  
 {  
   int ch;  
   do  
   {  
     clrscr();  
     cout<<"EDIT"<<endl<<"1.roll no"<<endl<<"2.name";="" <br="">     cout<<endl<<"3.subject"<<endl<<"4.sub code"<<endl<<"5.int="" assesment";="" <br="">     cout<<endl<<"6.uni exam"<<endl<<"7.exit";="" <br="">     cin>>ch;  
     switch(ch)  
     {  
       case 1:  
          cout<<endl<<"new roll="" no="" :="" ";="" <br="">          cin>>S->rno;  
          break;  
       case 2:  
          cout<<endl<<"new name="" :="" ";="" <br="">          gets(S->name);  
          break;  
       case 3:  
          cout<<endl<<"new subject="" :="" ";="" <br="">          cin>>S->sub;  
          break;  
       case 4:  
          cout<<endl<<"new code="" :="" ";="" <br="">          cin>>S->sub_code;  
          break;  
       case 5:  
          cout<<endl<<"new int="" assessment="" :="" ";="" <br="">          cin>>internal;  
          break;  
       case 6:  
          cout<<endl<<"new university="" marks="" :="" ";="" <br="">          cin>>uni_marks;  
          break;  
       case 7:  
          break;  
       default:  
           cout<<"Invalid Choice";  
     }  
   }while(ch!=7);  
 }  
 void main()  
 {  
   fstream inoutf;  
   ifstream inf;  
   student S;  
   assessment A;  
   int ch,flag=0,ct=0;  
   int r;  
   char c;  
   do  
   {  
     clrscr();  
     flag=0;  
     A.menu();  
     cout<<"\n\nEnter your choice : ";  
     cin>>ch;  
     clrscr();  
     switch(ch)  
     {  
       case 1:  
          inoutf.open("student.txt",ios::out|ios::binary);  
          do  
          {  
           A.input(&S);  
           inoutf.write((char*) &S,sizeof(S));  
           cout<<"Want to enter again y/n";  
           cin>>c;  
          }while(c=='y');  
          inoutf.close();  
          break;  
       case 2:  
          inf.open("student.txt",ios::in|ios::binary );  
          inf.seekg(0);  
          cout<<"\nRNo\tName\tSub\tCode\tAsmnt\tMarks";  
          //while(!inf.eof())  
          while(inf.read((char*)&S,sizeof(S)))  
          {  
           A.display(&S);  
          }  
          inf.close();  
          break;  
       case 3:  
          inoutf.open("student.txt",ios::out|ios::binary|ios::app);  
          inoutf.clear();  
          A.input(&S);  
          inoutf.write((char*)&S,sizeof(S));  
          inoutf.close();  
          break;  
       case 4:  
          cout<<"Enter Roll no to be deleted : ";  
          cin>>r;  
          inf.open("student.txt",ios::in|ios:: binary);  
          inoutf.open("temp.txt",ios::in|ios::out|ios::binary|ios::app);  
          inf.seekg(0);  
          while(inf.read((char*) & S,sizeof(S)))  
          {  
           if(r==A.rlno(&S))  
           {  
             flag=1;  
             //break;  
           }  
           else  
           {  
             inoutf.write((char*)&S,sizeof(S));  
           }  
          }  
          if(flag!=1)  
           cout<<"\n\nRoll no not found";  
          else  
           cout<<"\n\nDeleted";  
          inf.close();  
          inoutf.close();  
          remove("student.txt");  
          rename("temp.txt","student.txt");  
          break;  
       case 5:  
          ct=0;  
          cout<<"Enter Roll no to be modified : ";  
          cin>>r;  
          inoutf.open("student.txt",ios::in|ios:: binary|ios::out);  
          inoutf.seekg(0);  
          while(inoutf.read((char*) & S,sizeof(S)))  
          {  
           if(r==A.rlno(&S))  
           {  
             flag=1;  
             break;  
           }  
           ct++;  
          }  
          if(flag!=1)  
           cout<<"\n\nRoll no not found";  
          else  
          {  
           ct=ct*sizeof(S);  
           inoutf.seekg(ct,ios::beg);  
           A.modify(&S);  
           inoutf.write((char*)&S,sizeof(S));  
          }  
          inoutf.close();  
          break;  
       case 6:  
          inf.open("student.txt",ios::in |ios::binary );  
          inf.seekg(0);  
          cout<<"Enter Roll no to be searched : ";  
          cin>>r;  
          //while(!inf.eof())  
          while(inf.read((char*)&S,sizeof(S)))  
          {  
           if(r==A.rlno(&S))  
           {  
             flag=1;  
             break;  
           }  
           else  
             flag=0;  
          }  
          if(flag==1)  
          {  
           cout<<"\n\nRecord found";  
           cout<<"\nRNo\tName\tSub\tCode\tAsmnt\tMarks";  
           A.display(&S);  
          }  
          else  
           cout<<"\nRecord not found";  
          inf.close();  
       case 7:  
          break;  
       default:  
           cout<<"Invalid dirn";  
     }  
     getch();  
   }while(ch!=7);  
  inoutf.close();  
 }

 

Other Projects to Try:

  1. Cricket Database Project
  2. Cricket Database project using C++
  3. Friend Function Implementation using C++
  4. Student Database in C Language
  5. Operator Overloading on String Functions C++ Language

Filed Under: C Assignments, Computer Graphics Tagged With: Computer Graphics

  • Page 1
  • Page 2
  • Page 3
  • Go to Next Page »

Primary Sidebar

Tags

.Net Projects Download Android Project Ideas Android Projects Angular 2 Assembly Codes C # Projects C & C++ Projects C++ Projects Class Diagrams Computer Graphics Database Project Data Mining Projects DataScience Projects Datastructure Assignments Download Visual Basic Projects Electronics project Hadoop Projects Installation Guides Internet of Things Project IOS Projects Java Java Interview Questions Java Projects JavaScript JavaScript Projects java tutorial JSON JSP Projects Mechanical Projects Mongodb Networking Projects Node JS Projects OS Problems php Projects Placement Papers Project Ideas Python Projects seminar and presentation Struts

Search this Website


Footer

Download Java Project
Download Visual Basic Projects
Download .Net Projects
Download VB Projects
Download C++ Projects
Download NodeJs Projects
Download School Projects
Download School Projects
Ask Questions - Forum
Latest Projects Ideas
Assembly Codes
Datastructure Assignments
Computer Graphics Lab
Operating system Lab
australia-and-India-flag
  • Home
  • About me
  • Contact Form
  • Submit Your Work
  • Site Map
  • Privacy Policy