Saturday, July 15, 2017

Using Structure in C++

A very simple program to demonstrate how to use structure in C++ the code is very easy to understand and use.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.




Program Listing

#include <iostream>

using namespace std;

struct new_person {
    string name,address;
    int age;
};

main() {
    new_person sample;

    cout << "Enter your name : ";
    getline(cin,sample.name);
    cout << "\nEnter your Address : ";
    getline(cin,sample.address);
    cout << "\nEnter your Age : ";
    cin >> sample.age;


    cout << "\n\nName    : " << sample.name;
    cout << "\n\nAddress : " << sample.address;
    cout << "\n\nAge     : " << sample.age;
    cout << "\n\n";
    system("pause");

}

No comments:

Post a Comment