HackerRank C++ Structs




struct is a way to combine multiple fields to represent a composite data structure, which further lays the foundation for Object Oriented Programming. For example, we can store details related to a student in a struct consisting of his age (int), first_name (string), last_name (string) and standard (int).



  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7. struct Student
  8. {
  9. int age,standard;
  10. string first_name,last_name;
  11. };
  12. int main()
  13. {
  14. Student st;
  15. cin >> st.age >> st.first_name >> st.last_name >> st.standard;
  16. cout << st.age << " " << st.first_name << " " << st.last_name << " " << st.standard;
  17. return 0;
  18. }
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube