skip to main
|
skip to sidebar
C++ Programs
Based on cusat cs 3rd sem 2009 lab cycle
Thursday, May 20, 2010
Generic programming
22. Using generic programming concept, write function template for finding the minimum value in an array using bubble sort.
#include<iostream.h> #include<conio.h> template <class s> s sort(s a[],int n) { int i,j; s t; for(i=0;i<n-1;i++) { for(j=n-1;i<j;j--) { if(a[j]<a[j-1]) { t=a[j]; a[j]=a[j-1]; a[j-1]=t; } } break; } return(a[0]); } void main() { clrscr(); int i,x,y,p[10],int_min,z; float q[10],float_min; char ch[10],ch_min; cout<<"\n Enter the size of integer array "; cin>>x; cout<<"\n Enter the elements of integer array "; for(i=0;i<x;i++) cin>>p[i]; cout<<"\n Enter the size of character array "; cin>>z; cout<<"\n Enter the elements of character array "; for(i=0;i<z;i++) cin>>ch[i]; cout<<"\n Enter the size of float array "; cin>>y; cout<<"\n Enter the elements of float array "; for(i=0;i<y;i++) cin>>q[i]; int_min=sort(p,x); float_min=sort(q,y); ch_min=sort(ch,z); cout<<"\nMinimum value in integer array is "<<int_min; cout<<"\nMinimum value in float array is "<<float_min; cout<<"\nMinimum value in character array is "<<ch_min; getch(); }
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
Home
8085 programming
Datastructure
Graphics programming
8086 Programming
LEX, YACC and parsers
Operating System
Programzz!
Add two date using operator overloading
Add two date using class
Decrement time by one using operator overloading(E...
Add two time using operator overloading(External q...
Compare two string. use operator overloading(Exter...
Matrix multiplcation(External Questn-2009)
Difference between two dates
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
Followers
Blog Archive
▼
2010
(29)
►
December
(2)
►
October
(4)
►
July
(1)
▼
May
(22)
Generic programming
File manipulation
Pure Virtual Function
Virtual Function
Multipath Inheritance
Hybrid Inheritance
Hierarchical inheritance
Addition of two distances using friend function
Class to class conversion
Basic to class and class to basic conversion
Operator functions as friend functions
Function overloading.
Static & Constant function
User defined string functions
Complex numbers using operator overloading.
Inline function
Add two time
Differnt temprature scale(Farenheit/celsius/kelvin).
Students details- using class
Students details- using structure
Check whether a date is valid or not
pass by value, pass by address, pass by refrence
About Me
Arun Ramesh
View my complete profile
No comments:
Post a Comment