google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading

Saturday, February 28, 2015

Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading

Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<float.h>
class bubble
{
public:void array(int ans);
       void array(float ans);
};
void bubble:: array(int ans)
       {
       cout<<"\n"<<ans;
       }
void bubble::array(float ans)
       {
       cout<<"\n"<<ans;
       }
int main()
{
bubble bb;
int i,j,n,a[20],temp=0;
float b[20];
clrscr();
cout<<"\n Enter how many integer number you want to enter:-";
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
n=n-1;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
n++;
cout<<"\n Integer array after sorting:-";
for(i=0;i<n;i++)
bb.array(a[i]);
cout<<"\n Enter how many float number you want to enter:-";
cin>>n;
for(i=0;i<n;i++)
cin>>b[i];
n=n-1;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(b[j]>b[j+1])
{
float(temp)=b[j];
b[j]=b[j+1];
b[j+1]=float(temp);
}
}
}
n++;
cout<<"\n Float array after sorting:-";
for(i=0;i<n;i++)
bb.array(b[i]);
getch();

return 0;
}

==================================================
OUTPUT

Enter how many integer number you want to enter:-5                             
9                                                                              
8                                                                              
7                                                                              
4
1                                                                              
                                                                               
Integer array after sorting:-                                                  
1                                                                              
4                                                                              
7                                                                              
8                                                                              
9  
                                                                           
Enter how many float number you want to enter:-4                               
6.3                                                                            
5.2                                                                            
4.2                                                                            
1.3                                                                            
                                                                               
Float array after sorting:-
1.3
4.2
5.2
6.3

रामायण

रामायण दशरथ की तीन पत्नियाँ – कौशल्या, सुमित्रा , कैकेयी दशरथ के चार पुत्र – राम,लक्ष्मण,भरत,शत्रुघ्न दशरथ: राम के पिता और कौशल के राजा कौशल...