Ask your own question, for FREE!
Mathematics 7 Online
OpenStudy (anonymous):

can any one help me to write an algorithm for my program (c++) ?

OpenStudy (anonymous):

pls

OpenStudy (kinggeorge):

This would be better in the Computer Science area, but I can try.

OpenStudy (anonymous):

#include<fstream.h> #include<iostream.h> #include<conio.h> class student { char name [25]; char grade; float marks; public: void getdata(void); void display(void); }; void student :: getdata(void) { char ch; cin.get(ch); cout<<"Enter name : "; cin.getline(name,25); cout<<"Enter grade : "; cin>>grade; cout<<"Enter marks : "; cin>>marks; cout<<"\n"; } void student :: display(void) { cout<<"NAME : ";puts(name); cout<<"MARKS : "<<marks; cout<<"GRADE : "<<grade; cout<<"\n"; } int main() { clrscr(); student arts[3]; fstream finlin; finlin.open("stu.dat",ios::in|ios :: out); if(!finlin) { cout<<"file cannot be opened !!!!!"; return 1; } cout<<"Enter details for 3 students "; for(int i=0;i<3;i++) { arts[i].getdata(); finlin.write((char *)&arts[i],size(arts[i])); } filin.seekg(0); file.close; return 0 }

OpenStudy (kinggeorge):

What exactly are you trying to write here?

OpenStudy (anonymous):

i am using a file program to input and display 3 student details

OpenStudy (kinggeorge):

And what's going wrong for you?

OpenStudy (anonymous):

i want to write the algoritm for this program

OpenStudy (kinggeorge):

As far as I can tell, the algorithm is correct, you just have some errors you need to fix. At least, as far as inputting the student details. I can't see any part that displays the details.

OpenStudy (anonymous):

k

OpenStudy (anonymous):

i'll check it out thanks

OpenStudy (kinggeorge):

To display them, it should be almost the same, but you use the display function in the class instead of the getdata

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!