Professional Documents
Culture Documents
Sample Program
Sample Program
#include<fstream.h> #include<iostream.h> int main() { Ofstream filename; filename.open(student.txt); filename<<Hello world; filename.close();
Program 5 Program to get information from a file and display the information with the given choice (Initially you have to create a text file named objects as chair 0 pen 0 pencil 0 Alcohol - ! fuel -"0 #ruits !! medicines "!$ %xample&
#include<fstream.h> #include<iostream.h> int .etwhatuwant(); 2oid displa3items(int x); int main() { int whatuwant; whatuwant 4 .etwhatuwant(); while(whatuwant546) { switch(whatuwant) { case 78 displa3items(7); 9rea); case :8 displa3items(:); 9rea); case ;8 displa3items(;); 9rea); whatuwant 4 .etwhatuwant();
11.etwhatuwant function int .etwhatuwant() { int choice; cout<<7<plain items<<endl; cout<<:<harmful items<<endl; cout<<;<helpful items<<endl; cout<<6<plain items<<endl; cin>>choice; return choice;
11displa3item function 2oid displa3items(int x) { ifstream filename(o9=ects.txt); strin. name; dou9le 2alue; if(x447) { while(filename>>name>>2alue) { if(2alue44>) { cout<<name<<//<<num9er<<endl;