0% found this document useful (0 votes)
6 views1 page

C++ Program for Sorting User Data

Uploaded by

thomas national
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

C++ Program for Sorting User Data

Uploaded by

thomas national
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <iostream> swap(a[i],a[j]);

using namespace std; }

struct nc{

int age;
else if(a[i].age==a[j].age&&a[i].name>a[j].name )
string name;
{
char gender;
swap(a[i],a[j]);
};
}
int main(int argc, char** argv) {

nc a[3];

int i,j; else if( a[i].age==a[j].age &&a[i].name==a[j].name && a[i].gender>a[i].gender)

swap(a[i],a[j]);
for(i=0;i<3;i++)
}
{
}
cout<<"Enter your name";
}
cin>>a[i].name;
cout<<"Name"<<"\t"<<"Age"<<"\t"<<"Gender"<<endl;
cout<<"Enter your age";
for(i=0;i<3;i++)
cin>>a[i].age;
{
cout<<"Enter your gender(F/M)";
cout<<a[i].name<<"\t"<<a[i].age<<"\t"<<a[i].gender<<endl;
cin>>a[i].gender;
}
cout<<endl;
return 0;
}
}

for(i=0;i<3;i++)

for(j=i+1;j<3;j++)

if(a[i].age>a[j].age)

You might also like