Write a C++ Program using Concept of array of object.


SUBMITTED BY: Nrupeshsinh

DATE: July 4, 2016, 1:54 p.m.

FORMAT: Text only

SIZE: 652 Bytes

HITS: 343

  1. # include<iostream.h>
  2. # include<conio.h>
  3. class Library
  4. {
  5. public:
  6. char name[20];
  7. float price;
  8. void bookname();
  9. void bookprice();
  10. };
  11. void Library :: bookname()
  12. {
  13. cout<<"enter name=";
  14. cin>>name;
  15. cout<<"enter price";
  16. cin>>price;
  17. }
  18. void Library :: bookprice()
  19. {
  20. cout<<"NAME="<<name<<endl;
  21. cout<<"PRICE="<<price<<endl;
  22. }
  23. void main()
  24. {
  25. clrscr();
  26. int i;
  27. Library Library1[5];
  28. for(i=0; i<5; i++)
  29. {
  30. cout<<"Library Details"<<endl;
  31. cout<<"book name"<<i+1<<endl;
  32. Library1[i].bookname();
  33. }
  34. cout<<"\n";
  35. for(i=0; i<5; i++)
  36. {
  37. cout<<"book price"<<i+1<<endl;
  38. Library1[i].bookprice();
  39. }
  40. getch();
  41. }

comments powered by Disqus