0% found this document useful (0 votes)
8 views23 pages

Filing All Combine

C++ codes

Uploaded by

xirixim311
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views23 pages

Filing All Combine

C++ codes

Uploaded by

xirixim311
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Searching Program

# include <conio.h>

# include <stdio.h>

# include <iostream.h>

# include <string.h>

# include <process.h>

void main()

FILE *f;

f=fopen("Marks.dat","rb");

int rno,found=0;

float tot,per;

struct myrecord

int roll_no;

char name[15];
float it,win,word,excel,pp;

};

struct myrecord r;

clrscr();

gotoxy(15,3);

cout<<"Enter Roll Number to Search Record";

cin>>rno;

if(rno==0)

exit(1);

while(!feof(f))

fread(&r,sizeof(r),1,f);
if(r.roll_no==rno)

found=1;

clrscr();

gotoxy(10,5);

cout<<"Roll Number is "<<r.roll_no;

gotoxy(10,6);

cout<<"Student's Name is "<<r.name;

gotoxy(10,7);

cout<<"IT Marks is "<<r.it;

gotoxy(10,8);

cout<<"WINDOWS Marks is "<<r.win;


gotoxy(10,9);

cout<<"WORD Marks is "<<r.word;

gotoxy(10,10);

cout<<"EXCEL Marks is "<<r.excel;

gotoxy(10,11);

cout<<"PP Marks is "<<r.pp;

tot=r.it+r.win+r.word+r.excel+r.pp;

per=(tot*100)/500;

gotoxy(10,12);

cout<<"Total Marks is "<<tot;

gotoxy(10,13);

cout<<"Percetage is "<<per;
getch();

else

continue;

fclose(f);

if(found==0)

clrscr();

gotoxy(15,5);

cout<<"Record Not Found";

getch();

}
Data given (Writing) Program

# include <conio.h>

# include <stdio.h>

# include <iostream.h>

# include <string.h>

void data_given()

FILE *f;

f=fopen("Marks.dat","ab");

struct myrecord

int roll_no;

char name[15];

float it,win,word,excel,pp;

};

struct myrecord r;
while(1)

gotoxy(10,5);

cout<<"Enter Roll No ";

cin>>r.roll_no;

if(r.roll_no==0)

break;

gotoxy(10,6);

cout<<"Enter Student Name ";

gets(r.name);

gotoxy(10,7);

cout<<"Enter IT Marks ";

cin>>r.it;

gotoxy(10,8);

cout<<"Enter Windows Marks ";


cin>>r.win;

gotoxy(10,9);

cout<<"Enter Word Marks ";

cin>>r.word;

gotoxy(10,10);

cout<<"Enter Excel Marks ";

cin>>r.excel;

gotoxy(10,11);

cout<<"Enter Power Point Marks ";

cin>>r.pp;

fwrite(&r,sizeof(r),1,f);

fclose(f);

void disp()
{

char h1[40]="FAITH College of Information Technology";

char h2[40]="Marks Certificate";

clrscr();

gotoxy((80-strlen(h1))/2,1);

cout<<h1;

gotoxy((80-strlen(h2))/2,2);

cout<<h2;

void main()

disp();

data_given();
getch();

Updating Program

# include <conio.h>

# include <stdio.h>

# include <iostream.h>

# include <string.h>

# include <process.h>

void main()

FILE *f,*t;

f=fopen("Marks.dat","rb");

t=fopen("temp.dat","wb");

struct myrecord
{

int roll_no;

char name[15];

float it,win,word,excel,pp;

};

int rno,found=1;

struct myrecord r;

clrscr();

gotoxy(15,3);

cout<<"Enter Roll Number to Update the Record";

cin>>rno;

if(rno==0)

exit(1);

while(!feof(f))
{

clrscr();

fread(&r,sizeof(r),1,f);

if(r.roll_no==rno)

found=1;

gotoxy(10,5);

cout<<"Enter Roll No to Update ";

cin>>r.roll_no;

gotoxy(10,6);

cout<<"Enter Student Name to Update ";

gets(r.name);

gotoxy(10,7);
cout<<"Enter IT Marks to Update ";

cin>>r.it;

gotoxy(10,8);

cout<<"Enter Windows Marks to Update ";

cin>>r.win;

gotoxy(10,9);

cout<<"Enter Word Marks to Update ";

cin>>r.word;

gotoxy(10,10);

cout<<"Enter Excel Marks to Update ";

cin>>r.excel;

gotoxy(10,11);
cout<<"Enter Power Point Marks to Update ";

cin>>r.pp;

fwrite(&r,sizeof(r),1,t);

else

fwrite(&r,sizeof(r),1,t);

fclose(f);

fclose(t);

if(found==1)

clrscr();

gotoxy(15,5);
cout<<"Record Found and Update";

unlink("Marks.dat");

rename("temp.dat","Marks.dat");

getch();

else

clrscr();

gotoxy(15,5);

cout<<"Record Not Found";

getch();

}
Deleting Program

# include <conio.h>

# include <stdio.h>

# include <iostream.h>

# include <string.h>

# include <process.h>

void main()

FILE *f,*t;

f=fopen("Marks.dat","rb");

t=fopen("temp.dat","wb");

int rno,found=1;

float tot,per;

struct myrecord

int roll_no;
char name[15];

float it,win,word,excel,pp;

};

struct myrecord r;

clrscr();

gotoxy(15,3);

cout<<"Enter Roll Number to Delete Record";

cin>>rno;

if(rno==0)

exit(1);

while(!feof(f))

fread(&r,sizeof(r),1,f);

if(r.roll_no==rno)

{
found=1;

continue;

else

fwrite(&r,sizeof(r),1,t);

fclose(f);

fclose(t);

if(found==1)

clrscr();

gotoxy(15,5);

cout<<"Record Found and Deleted";

unlink("Marks.dat");
rename("temp.dat","Marks.dat");

getch();

else

clrscr();

gotoxy(15,5);

cout<<"Record Not Found";

getch();

}
Printing (Traversing ) Progam

# include <conio.h>

# include <stdio.h>

# include <iostream.h>

# include <string.h>

void main()

FILE *f;

f=fopen("Marks.dat","rb");

float tot,per;

struct myrecord

int roll_no;

char name[15];
float it,win,word,excel,pp;

};

struct myrecord r;

while(!feof(f))

clrscr();

fread(&r,sizeof(r),1,f);

gotoxy(10,5);

cout<<"Roll Number is "<<r.roll_no;

gotoxy(10,6);

cout<<"Student's Name is "<<r.name;

gotoxy(10,7);

cout<<"IT Marks is "<<r.it;


gotoxy(10,8);

cout<<"WINDOWS Marks is "<<r.win;

gotoxy(10,9);

cout<<"WORD Marks is "<<r.word;

gotoxy(10,10);

cout<<"EXCEL Marks is "<<r.excel;

gotoxy(10,11);

cout<<"PP Marks is "<<r.pp;

tot=r.it+r.win+r.word+r.excel+r.pp;

per=(tot*100)/500;

gotoxy(10,12);

cout<<"Total Marks is "<<tot;


gotoxy(10,13);

cout<<"Percetage is "<<per;

getch();

fclose(f);

You might also like