We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.

read to code given below and learn how to use structures in c++

#include<iostream>
#include<string>
using namespace std;
// badshah.hazor@gmail.com
// structure always start with keyword struct then name of structure
struct Worker{ // where Worker is a name of structure
string name;
string address;
double salary;
};
main(){
// creating objects inside the main function
struct Worker Ali, Assad; // we can define more then two objects as per requirments
// we will bind these object with structure's variable by using the dot "." oprator
Ali.name="Ali";
Ali.address="Home";
Ali.salary=20000;
Assad.name="Assad";
Assad.address="House";
Assad.salary=25000;
// we have saved the information of both Ali and Assad inside the structure
// now we will retrive these all information that we have saved recently
cout"\t\t\t\t****Badshah****\n\n";
cout"Name :"Ali.nameendl;
cout"Address:"Ali.addressendl;
cout"Salary :"Ali.salaryendlendl;
cout"\t\t\tSecond Worker\n\n";
cout"Name :"Assad.nameendl;
cout"Address:"Assad.addressendl;
cout"Salary :"Assad.salaryendlendl;
coutendl;
system("pause");
}

Please download the attachment file given below if the above code doesn't work 

Views: 298

Attachments:

Replies to This Discussion

gud wrk keep it up

Thanks alot  for this aappreciation

RSS

© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service