#include<
iostream
>
#include<
conio.h
>
using namespace std;
int main()
{
int i,j,n,temp;
cout<<"Enter size of array : ";
cin>>n;
int *arr=new int[n];
cout<<"Enter elements of array\n";
for(i=0;i<
n
;i++)
{
cin>>arr[i];
}
cout<<"Elements of array\n";
for(i=0;i<
n
;i++)
{
cout<<
arr[i]<<"\t";
}
cout<<"\nSorted elements of array\n";
for(i=0;i<
n
;i++)
{
for(j=0;j<
n-i-1
;j++)
{
if(arr[j]>
arr[j+1]
)
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
for(i=0;i<
n
;i++)
{
cout<<
arr[i]
<<"\t";
}
getch();
return 0;
}
Friday, 13 October 2017
Sorting of Array in Ascending Order in c++
Subscribe to:
Post Comments (Atom)
Python Program to find Fabonacci
fabtab={} def fabonacci(n): fabtab[0]=0 fabtab[1]=1 for i in range(2,n+1): fabtab[i]=fabtab[i-1]+fabtab[i-2] ...
-
#include stdio.h > #include stdlib.h > #include conio.h > int arr[100], size=0; void insert_beg(); void insert_pos(); void inser...
-
#include iostream> #include conio.h > using namespace std; int main() { int n,num,first=0,middle,last; ...
-
#include iostream > #include conio.h > using namespace std; int main() { float radius; double area; ...
No comments:
Post a Comment