Wednesday, September 12, 2018

Nested Structure in C++

Here is a very simple program that I wrote to demonstrate how nested structure works in C++?

I am currently accepting programming work, it projects, school 

programming projects, thesis and capstone projects, IT consulting 

work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise in my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

My personal website is http://www.jakerpomperada.com



Sample Program Output


Program Listing

// employees.cpp
// Author    : Mr. Jake R. Pomperada, BSCS,MAED-IT
// Date      : September 4, 2018   Tuesday  8:04 AM
// Location  : Bacolod City, Negros Occidental Philippines.
// Website   : http://www.jakerpomperada.com
// Email     : jakerpomperada@jakerpomperada.com and jakerpomperada@gmail.com
// Tool      : Dev C++ Version 5.11

#include <iostream>
#include <iomanip>

using namespace std;

struct contact_details    // structure tag
{
    char address[200];
int telephone;
    int mobile;
    char email[200];
};
struct emp             // structure tag
{
int empno;
char name[200];
char position[200];
contact_details user;
/* See, user is a structure variable itself (of type
      contact_details) and it is member of another structure,
   the emp structure. */
float basic;
};

int main()
{
emp user_details;   // create structure variable
system("COLOR F0"); 
cout <<"\n\n";
cout << fixed << setprecision(2);
cout << "\tNested Structure Demonstration in C++";
cout <<"\n\n";
cout<<"\tEmployee Number  : ";
cin>>user_details.empno;
cin.ignore();
cout<<"\tEmployee Name    : ";
gets(user_details.name);
cout<<"\tPosition         : ";
gets(user_details.position);
cout<<"\tBasic Salary     : PHP ";
cin >> user_details.basic;
cin.ignore();
cout<<"\tHome Address     : ";
gets(user_details.user.address);
cout<<"\tEmail Address    : ";
gets(user_details.user.email);
cout<<"\tTelephone Number : ";
cin>>user_details.user.telephone;
cout<<"\tMobile Number    : ";
cin >> user_details.user.mobile;
cout<<"\n\n";
cout<<"\tEMPLOYEE DISPLAY RECORD";
    cout <<"\n\n";
cout<<"\n\tEmployee Number     : "<<user_details.empno;
cout<<"\n\tEmployee Name       : "<<user_details.name;
cout<<"\n\tPosition            : "<<user_details.position;
cout<<"\n\tHome Address        : "<<user_details.user.address;
cout<<"\n\tEmail Address       : "<<user_details.user.email;
cout<<"\n\tTelephone Number    : "<<user_details.user.telephone;
cout<<"\n\tMobile Number       : "<<user_details.user.mobile;
cout<<"\n\tBasic Salary Pay    : PHP "<<user_details.basic;
cout<<"\n";
    cout <<"\n\n";
    cout <<"\tEND OF PROGRAM";
    cout <<"\n\n";
    system("pause");
}






No comments:

Post a Comment