Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Structures in C++

    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 563
    Comment on it

    Structures in C++ is a collection of dissimilar data types .Structures is denoted by struct keyword .In structures we can access different data in a single block.It is usually used to keep the track of different kinds of records in a single block.Now am discussing an example illustrating the records of an employee in a company.

    1. #include <iostream>
    2. using namespace std;
    3.  
    4. struct employee
    5. {
    6. char name[100];
    7. int employee ID;
    8. int age;
    9. int account no.;
    10. float salary;
    11. };
    12.  
    13. int main() {
    14.  
    15. employee E1;
    16.  
    17. cout << "Enter your Full name: ";
    18. cin.get(E1.name, 100);
    19. cout << Enter your employee ID: ;
    20. cin >> E1.emplyee ID;
    21. cout << "Enter your age: ";
    22. cin >> E1.age;
    23. cout << "Enter your account no.: ";
    24. cin >> E1.account no.;
    25. cout << "Enter your salary: ";
    26. cin >> E1.salary;
    27.  
    28. cout << "\nDisplay Records ." << endl;
    29. cout << "Name: " << E1.name << endl;
    30. cout << Employee ID: <<E1.Employee ID<< end1;
    31. cout <<"Age: " << E1.age << endl;
    32. cout <<"Account no.: " << E1.account no. << endl;
    33. cout << "Salary: " << E1.salary;
    34.  
    35. return 0;
    36. }

    Output

    1. Enter Your Full nam Outpute: Samakshi Raheja
    2. Enter your Employee ID:2245
    3. Enter your age: 25
    4. Enter your account no.:130002345
    5. Enter your salary: 12000.45
    6.  
    7. Display Records.
    8. Name: Samakshi Raheja
    9. Employee ID:2245
    10. Age: 25
    11. Account no.:130002345
    12. Salary: 12000.45

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: