Q:

C++ Program For Employee Information Using Nested Structure

belongs to collection: Examples of Structure C++ Programming

0

What Is Structure?

The structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record. The structure is used to represent a record. Suppose you want to store a record of Student which consists of student name, address, roll number and age.


Defining a structure

struct keyword is used to define a structure. struct define a new data type which is a collection of different type of data.

Syntax :

struct structure_name

{
//Statements

//Statements
//Statements
//Statements
};

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


struct Address
{
char HouseNo[25];
char City[25];
char PinCode[25];
};

struct Employee
{
int Id;
char Name[25];
float Salary;
struct Address Add;
};

int main()
{

int i;

Employee E;

cout << "\n\tEnter Employee Id : ";
cin >> E.Id;

cout << "\n\tEnter Employee Name : ";
cin >> E.Name;

cout << "\n\tEnter Employee Salary : ";
cin >> E.Salary;

cout << "\n\tEnter Employee House No : ";
cin >> E.Add.HouseNo;

cout << "\n\tEnter Employee City : ";
cin >> E.Add.City;

cout << "\n\tEnter Employee House No : ";
cin >> E.Add.PinCode;

cout << "\nDetails of Employees";

cout << "\n\tEmployee Id : " << E.Id;
cout << "\n\tEmployee Name : " << E.Name;
cout << "\n\tEmployee Salary : " << E.Salary;
cout << "\n\tEmployee House No : " << E.Add.HouseNo;
cout << "\n\tEmployee City : " << E.Add.City;
cout << "\n\tEmployee House No : " << E.Add.PinCode;

return 0;
}

 

Output

Enter Employee Id : 101

Enter Employee Name : mohamad

Enter Employee Salary : 30000

Enter Employee House No : 89

Enter Employee City : dubi

Enter Employee House No : 69

Details of Employees

Employee Id : 101

Employee Name : mohamad

Employee Salary : 30000

Employee House No : 89

Employee City : dubi

Employee House No : 69

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program For Store Book Details Using Structure... >>
<< C++ Program To Add Two Distances (in inch-feet) Us...