Horje
appdivind c++ stuctures Code Example
appdivind c++ stuctures
#include<iostream>
using namespace std;
struct voter
{
    string name,add;
    int id;
};
//declaring function
//structure object is the parameter
void display(struct voter v)
{
    cout<<"\nVoter ID: "<<v.id;
    cout<<"\nName: "<<v.name;
    cout<<"\nAddress: "<<v.add<<"\n";
}
int main()
{
    voter v1;
    v1.id=1452145;
    v1.name="Debasis Jana";
    v1.add="Kolkata, West Bengal";
    //calling the function using structure object
    display(v1);
    return 0;
}
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<<"\nName: "<<E1.name;
    cout<<"\nAddress: "<<E1.add;
    cout<<"\nDA+TA: "<<((E1.s.DA)+(E1.s.TA));
    cout<<"\nTotal Salary: "<<((E1.s.DA)+(E1.s.TA)+(E1.s.Total))<<"\n";

}
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);

}




Cpp

Related
operand-- c++ Code Example operand-- c++ Code Example
CodeChef Starters 30 Division 4 (Rated) Swapping Chefs Way Code Example CodeChef Starters 30 Division 4 (Rated) Swapping Chefs Way Code Example
c++ cout format specifier for correct number of decimal points Code Example c++ cout format specifier for correct number of decimal points Code Example
c++ functions dynamic vector Code Example c++ functions dynamic vector Code Example
 convert Celsius to Fahrenheit Code Example convert Celsius to Fahrenheit Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12