Create a Structure called employee with the following details as variables within it.
1. Name of the employee
2. Age
3. Designation
4. Salary
Write a C++ program to create array of objects for the structure to access these and print the name, age, designation and salary.




Implementation of the above problem:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct bio
{
char name[20];
int age;
float sal;
char designation[20];
};
void main()
{
struct bio info[2];
for(int i=0;i<2;i++)
{
cout<<"Enter the data : name, age, salary, designation"<<endl;
cin>>info[i].name>>info[i].age>>info[i].sal>>info[i].designation;
}
for(i=0;i<2;i++)
{
cout<<"Given Data for obj["<<i<<"]:- "<<endl;
cout<<"+++++++++++++++++++++++++++\n";
cout<<"Name : "<<info[i].name<<endl;
cout<<"Age : "<<info[i].age<<endl;
cout<<"Salary : "<<info[i].sal<<endl;
cout<<"Address : "<<info[i].designation<<endl;
}
cout<<"Size of the structure Student is :"<<sizeof(info[0]);



getch();
}


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: