Last active
March 5, 2020 17:37
-
-
Save javedbaloch4/88fadd5cf79698b77ff2adcb026fc239 to your computer and use it in GitHub Desktop.
This program, will ask user info using structs and for input using functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include<iostream> | |
| using namespace std; | |
| struct Person { | |
| string name; | |
| int age; | |
| double salary; | |
| }; | |
| // ProtoType | |
| Person inputPerson(Person); | |
| void displayData(Person); | |
| int main() { | |
| cout << "How Many Person you need to enter? "; | |
| int size; | |
| cin >> size; | |
| for (int i = 0; i < size; i++) { | |
| Person person[size]; | |
| person[i] = inputPerson(person[i]); | |
| displayData(person[i]); | |
| } | |
| return 0; | |
| } | |
| Person inputPerson(Person p) { | |
| cout << "Name : "; | |
| cin >> p.name; | |
| cout << "Age : "; | |
| cin >> p.age; | |
| cout << "Salary : "; | |
| cin >> p.salary; | |
| return p; | |
| } | |
| void displayData(Person p) { | |
| cout << "\nName is : " << p.name << endl; | |
| cout << "Age is : " << p.age << endl; | |
| cout << "Salary is : " << p.salary << endl << endl; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment