AbdulFathaah

details of a student C++

Dec 10th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. /*program to read and display details of a student*/
  2. #include<iostream.h>
  3. #include<conio.h>
  4.  
  5. class student //class declaration
  6. {
  7. private : int rollno;
  8. char name[20];
  9. float m1,m2,m3;
  10. public : void display();
  11. void read();
  12. };
  13. void student :: read() //definition of member function outside class
  14. {
  15. cout<<"Enter Name of Student: ";
  16. cin>>name;
  17. cout<<"Enter Roll number: ";
  18. cin>>rollno;
  19. cout<<"Enter Mark Of Subject 1: ";
  20. cin>>m1;
  21. cout<<"Enter Mark of Subject 2: ";
  22. cin>>m2;
  23. cout<<"Enter Mark of subject 3: ";
  24. cin>>m3;
  25. }
  26. void student :: display()
  27. {
  28. cout<<name;
  29. cout<<rollno;
  30. cout<<"Mark 1: "<<m1;
  31. cout<<"Mark 2: "<<m2;
  32. cout<<"Mark 3: "<<m3;
  33. }
  34. int main() //main function
  35. {
  36. student obj1;
  37. obj1.read();
  38. obj1.display();
  39. getch();
  40. return 0;
  41. }
  42.  
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment