79) Write a program in C++ to input name and age of some person and write both name and age randomly?

#include<fstream.h> #include<ctype.h> #include<string.h> #include<conio.h> #define MAXNAME 40 class person { private:                 char name[MAXNAME];                 int age; public:                 void write(ofstream &os)                 {                                 os.write(name,strlen(name));                                 os<<ends;                                 os.write((char*)&age,sizeof(age));                 }                 int read(ifstream &is)                 {                                 is.get(name,MAXNAME,0);                                 name[is.gcount()]=0;                                 is.ignore(1);                                 is.read((char*)&age,sizeof(age));                                 return is.good();                 }                 friend ostream &operator<<(ostream... Continue Reading →

Advertisements

78) Write a program in C++ to input name roll no and marks of five subject in a class person and from I/O file. Calculate total marks and division. Total marks calculated with addition of five subject of marks and division calculate on total marks as given bellow?

Total marks Division          i.            >=300 First        ii.            >=225 and <300 Second       iii.            >=150 and <225 Third      iv.            <150 Fail Write roll no, name, total marks and division to an output file? #include<iostream.h> #include<fstream.h> #include<process.h> #include<conio.h> class student { private:                 char name[20];                 int rn,s1,s2,s3,s4,s5,tm,i,count; public:                 void inputoutput(); }; void... Continue Reading →

77) Write a program in C++ to input name and age option in a class person using a file operate records of this class using random file?

#include<iostream.h> #include<fstream.h> #include<process.h> #include<conio.h> class person { private:                 char name[20];                 int age,count,i; public:                 void inputoutput(); }; void person::inputoutput() {                 fstream infile;                 fstream outfile;                 infile.open("PersonIn.txt",ios::in);                 if(infile.fail())                                 {                                 cout<<"Input File Not Existent ";                                 getch();                                 exit(1);                                 }                 outfile.open("Person.txt",ios::out);                 infile>>count;                 for(i=1;i<=count;i++)                                 {                                ... Continue Reading →

76) An example of I/O file with formatting?

#include<iostream.h> #include<fstream.h> #include<conio.h> #include<process.h> void main() {                 clrscr();                 fstream infile;                 fstream outfile;                 int i,count,percentage;                 char name[20];                 infile.open("Student.txt",ios::in);                 if(infile.fail())                                 {                                 cout<<"Error: Student.txt File Non-Existent";                                 getch();                                 exit(1);                                 }                 outfile.open("Result.txt",ios::out);                 if(outfile.fail())                                 {                                 cout<<"Error: Unable To Open Result.txt In Write mode";                                 getch();... Continue Reading →

75) Write a program in C++ to input roll no and registration no of 10 student from an input file identity.txt. Input marks of three subject from another input file marks.txt of 10 student. Calculate total marks of all 10 student. Arrange and print roll no, registration no. and total marks in ascending order to output file named as ascend.txt. Rearrange and print roll no, registration no and total marks to another output file name as descend.txt?

#include<iostream.h> #include<conio.h> #include<fstream.h> void main() {                 int i,j,temp;                 int rn[10],reg[10],tm[10],s1,s2,s3;                 clrscr();                 ifstream identify("identify.txt");                 ifstream marks("marks.txt");                 ofstream ascend("ascend.txt");                 ofstream descend("descend.txt");                 for(i=0;i<10;i++)                                 {                                 identify>>rn[i]>>reg[i];                                 marks>>s1>>s2>>s3;                                 tm[i]=s1+s2+s3;                                 }                 for(i=0;i<9;i++)                                 for(j=i+1;j<10;j++)                                                 if(tm[j]<tm[i])                                                                 {                                                                 temp=tm[j]; tm[j]=tm[i]; tm[i]=temp;                                                                 temp=rn[j]; rn[j]=rn[i]; rn[i]=temp;                                                                ... Continue Reading →

74) Write a program in C++ to input roll no and marks of three subject of 10 student. Calculate total marks of all 10 student. Name of input file is marks.txt. Write roll no and total marks of only those students which total marks is greater than 300. Name of this output file is pass.txt. Write roll no and total marks of remaining student to another output file named as fail.txt?

#include<iostream.h> #include<fstream.h> #include<conio.h> void main() {                 int rn,s1,s2,s3,tm=0,i;                 clrscr();                 ifstream marks("marks.txt");                 ofstream pass("pass.txt");                 ofstream fail("fail.txt");                 for(i=0;i<10;i++)                                 {                                 marks>>rn>>s1>>s2>>s3;                                 tm=s1+s2+s3;                                 if(tm>=300)                                                 pass<<rn<<"\t"<<tm<<endl;                                 else                                                 fail<<rn<<"\t"<<tm<<endl;                                 }                 marks.close();                 pass.close();                 fail.close();                 getch(); }  

73) Write a program in C++ to input roll no and total marks from an input file of 10 student. Name of input file is marks.txt. write roll no and total marks of only those student two an output file which total marks is greater than equal to 300. Name of output file is result.txt?

#include<iostream.h> #include<conio.h> #include<fstream.h> void main() {                 int rn,tm,i;                 clrscr();                 ifstream marks("marks.txt");                 ofstream result("result.txt");                 for(i=0;i<10;i++)                                 {                                 marks>>rn>>tm;                                 if(tm>=300)                                                 result<<rn<<"\t"<<tm<<endl;                                 }                 marks.close();                 result.close();                 getch(); }  

71) Write a program in C++ to input roll no and marks of three subject of 10 student. Print roll no of only those student who secured 35 or more marks in every subject separately. Name of input file is marks.txt?

#include<iostream.h> #include<fstream.h> #include<conio.h> void main() {                 int rn,s1,s2,s3,i;                 clrscr();                 ifstream myfile;                 myfile.open("marks.txt");                 for(i=0;i<10;i++)                                 {                                 myfile>>rn;                                 myfile>>s1>>s2>>s3;                                 if(s1>=35 && s2>=35 && s3>=35)                                                 cout<<rn<<endl;                                 }                 myfile.close();                 getch(); }  

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: