#include<iostream> using namespace std; int main() { int i,j,n; cout<<"\nenter the no of integers : "; cin>>n; double a[n],temp; int k=n; cout<<"\nenter the integers : "; for(i=0;i<n;i++) { cin>>a[i]; } cout<<"\narray before sorting : "; for(i=0;i<n;i++) { cout<<a[i]<<" "; } cout<<"\n"; for(i=0;i<n-1;i++) { for(j=1;j<(n-i);j++) { if(a[j-1]>a[j]) { temp=a[j]; a[j]=a[j-1]; a[j-1]= temp; } } } cout<< "\narray after sorting :"; for(i=0;i<n;i++) { cout<< a[i]<< " "; } cout<<"\n"; return 0; }
Labels
Popular Posts
-
Typedef: Typedef is a keyword used to assign new names to existing data types. This is same like defining alias for the comma...
-
Name Visibility : Named entities, such as variables, functions, and compound types need to be declared before bein...
-
The four pillars of object oriented programming development : 1. Encapsulation : ...
Blog Archive
- March 2017 (1)
- March 2016 (1)
- October 2015 (1)
- September 2015 (1)
- August 2015 (5)
- July 2015 (2)
- June 2015 (4)
- January 2015 (4)
- December 2014 (5)
- November 2014 (1)
- October 2014 (1)
- September 2014 (3)
Powered by Blogger.