Advertisement
MSJAHID

Untitled

Sep 18th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4. class Student{
  5. public:
  6. long long int Roll;
  7. std:: string name;
  8. float Marks;
  9. void GetData();
  10. void Display();
  11. };
  12. void Student::GetData()
  13. {
  14. cout<<"Enter Roll : ";
  15. cin>>Roll;
  16. cout<<"Enter name : ";
  17. cin.getline(name,40);//getline(cin,name);
  18. cout<<"Enter Marks : ";
  19. cin>>Marks;
  20. }
  21. void Student::Display()
  22. {
  23. GetData();
  24. cout<<"\nRoll is : "<<Roll<<endl;
  25. cout<<"name is : "<<name<<endl;
  26. cout<<"Marks is : "<<Marks<<endl;
  27. if(Marks<0)
  28. cout<<"invalid Marks!"<<endl;
  29. }
  30. int main()
  31. {
  32. Student s;
  33. s.Display();
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement