


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



E.g. I am recognized by: First Name Last Name NIC / driving license Number My height etc.
First Name Last Name NIC Number Height
Usman Younis
E.g., struct NIC { int field1; int field2; int field3; };
struct Record { char first_name[10]; char last_name[10]; NIC Identification_number; int height; };
Structures (contd..)
We can also create arrays of structures
However, this might be a limitation, when we don’t know how many people are there in a village
Usman Younis
int temp_value = 0;
while(option != ‘n’) //Initialize the List { cout<<“Enter new item value”<<endl; cin>>temp_value; List* newLink = new List;
newLink->value = temp_value; newLink->next = FIRST;
FIRST = newLink; cout<<“Add another (y/n)? ”; cin>>option; }
Structures (contd..)
List* Temp = FIRST;
while(Temp != NULL) //Display the List { cout<<“Item’s value is”<<Temp->value<<endl; Temp = Temp->next; }
Temp = FIRST;
while(Temp != NULL) //Free the Memory { FIRST = Temp->next; delete Temp; Temp = FIRST; } }