Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- int main()
- {
- struct data
- {
- string country;
- string fathername;
- int age;
- };
- data NAME;
- data name[5]={"Ali", "Usman", "Sarmad", "Awais", "Junaid"};
- name[0]=(struct data){"Saudi Arabia","Tahir Awan",24};
- name[1]=(struct data){"England","Akram Khan",20};
- name[2]=(struct data){"China","Amjad Ali",20};
- name[3]=(struct data){"Syria","Ahmad Ali",19};
- name[4]=(struct data){"Oman","Zohaib Sultan",24};
- cout << "Enter Name of student/n";
- cin >> NAME;
- int j;
- for(int i=0; i<6; i++)
- {
- if(NAME==name[i])
- j=i;
- }
- cout << "We have following data for " << name[j]<< endl;
- cout << "Country: " << name[j].country << endl << "Father name: " << name[j].fathername << endl << "Age: " << name[j].age << endl;
- return 0;
- }