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


SUBMITTED BY: Nrupeshsinh

DATE: July 4, 2016, 2 p.m.

FORMAT: Text only

SIZE: 1.5 kB

HITS: 358

  1. # include<iostream.h>
  2. # include<conio.h>
  3. class student
  4. {
  5. public:
  6. char name[20],coursename[5];
  7. int m1,m2,m3,m4,m5,rollno,total;
  8. float per;
  9. void stuname();
  10. void course();
  11. void submarks();
  12. void percentage();
  13. void display();
  14. };
  15. void student :: stuname()
  16. {
  17. cout<<"enter name=";
  18. cin>>name;
  19. cout<<"enter roll no:";
  20. cin>>rollno;
  21. }
  22. void student :: course()
  23. {
  24. cout<<"enter course name:";
  25. cin>>coursename;
  26. }
  27. void student :: submarks()
  28. {
  29. cout<<"enter marks:\n";
  30. cin>>m1>>m2>>m3>>m4>>m5;
  31. }
  32. void student :: percentage()
  33. {
  34. total=m1+m2+m3+m4+m5;
  35. per=total/5;
  36. }
  37. void student :: display()
  38. {
  39. cout<<"Student name:"<<name<<endl;
  40. cout<<"Roll no:"<<rollno<<endl;
  41. cout<<"Course name:"<<coursename<<endl;
  42. cout<<"Marks:"<<m1<<endl;
  43. cout<<"Marks:"<<m2<<endl;
  44. cout<<"Marks:"<<m3<<endl;
  45. cout<<"Marks:"<<m4<<endl;
  46. cout<<"Marks:"<<m5<<endl;
  47. cout<<"Percentage:"<<per<<endl;
  48. }
  49. void main()
  50. {
  51. clrscr();
  52. int i;
  53. student class1[5];
  54. for(i=0; i<5; i++)
  55. {
  56. cout<<"student name:"<<i+1<<endl;
  57. class1[i].stuname();
  58. }
  59. cout<<"\n";
  60. for(i=0; i<5; i++)
  61. {
  62. cout<<"course name:"<<endl;
  63. class1[i].course();
  64. }
  65. cout<<"\n";
  66. for(i=0; i<5; i++)
  67. {
  68. cout<<"Marks:"<<i+1<<endl;
  69. class1[i].submarks();
  70. }
  71. cout<<"\n";
  72. for(i=0; i<5; i++)
  73. {
  74. cout<<"percentage:"<<i+1<<endl;
  75. class1[i].percentage();
  76. }
  77. cout<<"\n";
  78. for(i=0; i<5; i++)
  79. {
  80. cout<<"student Details:"<<endl;
  81. class1[i].display();
  82. }
  83. getch();
  84. }

comments powered by Disqus