Docstoc

SORTED NUMBER C++ PROGRAMING LECTURE

Document Sample
SORTED NUMBER C++ PROGRAMING LECTURE Powered By Docstoc
					1-// for sorted numbers


# include <iostream.h>
# include <stdlib.h>
int s (int* , int*);
main(){
int x[10];
int a,b,t;
for (int i=0; i<10; i++)
{
cout<<"Enter Number at position "<<i<<'\t';
cin>>x[i];
}cout<<"\n\nHere are the sorted numbers\n\n";
for(a=0; a<10; a++)
{
for(b=0; b<10; b++)
{
if (x[b]>x[b+1])
{
s (&x[b],&x[b+1]);
}
  }

cout<<'\t';
for (b=0; b<10; b++)
{
cout<<x[b]<<" ";
}
cout<<'\n'<<'\n';
if (s == 0)
break;

}
system("PAUSE");
}

int s (int*x,int*y)
{
int t;

t = *x;
*x = *y;
*y = t;}

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:10
posted:9/22/2012
language:simple
pages:1
Description: SORTED NUMBER C++ PROGRAMING LECTURE