C++ LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART- B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8

old

PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 . . .

write a c++ program to sort an array using function template

 
 //#include< conio.h >
#include< iostream >
using namespace std;

template< class bubble >
void bubblesort(bubble a[], int n)
{
	int i, j;
	for(i=0;i < n-1;i++)
	{
		for(j= i+1;j < n;j++)
		{
			if(a[i] > a[j])
			{
				bubble element;
				element = a[i];
				a[i] = a[j];
				a[j] = element;
			}
		}
	}
};

int main()
{ 

		int a[10];
		int size ;
		cout << "ENTER SIZE :" << endl;
		cin >> size;
 		cout << "\n ENTER ARRAY ELEMENYS: ";

		for(int i=0;i < size;i++)
		  cin >> a[i] ;
	//clrscr();
	bubblesort(a,size);
	cout<<"\nSorted Order Integers: ";
	for(int i=0;i < size;i++)
		cout << a[i] << "\n";
  
	//getch();
}