Saturday, July 15, 2017

Basics of Struct in C++


In this article shows you how to use basics of struct 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;
    int age;
    int val1;
    int val2;
};

main() {

 int sum_up=0;

    new_person jake;
    new_person boy = {"Boy Abunda",65};
    new_person solve;
    solve.val1 = 5;
    solve.val2 =10;

    sum_up = (solve.val1 + solve.val2);



    cout << "\n\n";

    jake.name = "Jake Rodriguez Pomperada";
    jake.age = 31;
    cout << "\t\t Basics of Struct in C++";
    cout << "\n\n";
    cout << jake.name <<  " " << " Age " <<jake.age;
    cout << "\n\n";
    cout << boy.name <<  " " << " Age " <<boy.age;
    cout << "\n\n";
    cout << "The sum of "<< solve.val1 << " and " <<
          solve.val2 << " is " << sum_up << ".";
    cout << "\n\n";
    system("pause");
}



No comments:

Post a Comment