Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

appdivind c++ stuctures

#include<iostream>
using namespace std;
struct salary
{
    int DA,TA,Total;
};
struct Employee
{
    string name,add;
    //declaring structure salary as a nested structure
    struct salary s;
};
void display(struct Employee E1)
{
    cout<<"
Name: "<<E1.name;
    cout<<"
Address: "<<E1.add;
    cout<<"
DA+TA: "<<((E1.s.DA)+(E1.s.TA));
    cout<<"
Total Salary: "<<((E1.s.DA)+(E1.s.TA)+(E1.s.Total))<<"
";

}
int main()
{
    Employee E;
    //adding values to the member of Employee structure
    E.name="Ankit";
    E.add="Pune";
    //Adding values to the member of salary structure
    E.s.DA=1400;
    E.s.TA=2800;
    E.s.Total=36000;
    //calling display function
    display(E);

}
Source by appdividend.com #
 
PREVIOUS NEXT
Tagged: #appdivind #stuctures
ADD COMMENT
Topic
Name
6+2 =