int main() { int x[10],i,y; cout<<"Please input 10 integers: "<<endl; for(i=0;i<10;i++) { cin>>x[i]; } cout<<" You have entered the following numbers: \n"; for(int i =0;i<10;i++) cout<<" "<<x[i]<<" "; cout<<"\n "; //sorting: for(i=0;i<10;i++) { for(y=0;y<i;y++) { if(x[i]>x[y]) { int t=x[i]; x[i]=x[y]; x[y]=t; } } } cout<<endl; //finding the closest pair after sorting: int a=x[0]; int b=x[1]; int jo,ann; ann=a-b; for(i=0;i<=8;i++) { jo=x[i]-x[i+1]; if (jo<ann) { a=x[i+1]; b=x[i]; ann=jo; } } cout<<" The closest pair among the group are, " <<a<< " and " <<b<<endl; system("pause"); return 0; }