Write A Program for sorting of n numbers (bubble sort)

#include<stdio.h> #include<conio.h> void main ( ) { int x [100],n; i, j, temp; printf (“enter size of the array”);...

#include<stdio.h>
#include<conio.h>
void main ( )
{
int x [100],n; i, j, temp;
printf (“enter size of the array”);
scanf ("%d”, & n);
printf (“\n enter elements into an array");
for ( i =0; i < n; i++)
scanf (“%d" &x[i]);
for ( i =0; i < n; i++)
{
for ( j = i +1; j < n, j++)
{
if (x[i] > x[j])
{
temp = x [i];
x[i] = x[j];
x[j] = temp;
}
}
}
printf (“\n elements after sorting \n”);
for ( i =0, i < n; i++)
printf (“\t %d”,x[i]);
getch ( );
}

Out Put:

enter size of the array 5
enter elements into an array 7 3 6 4 5
elements after sorting 3 4 5 6 7

Related

Write A Program for calculating NCR value

# include<stdio.h> #include<conio.h> void main ( )           { int n, r, ncr, a, b, c, i; clrscr ( ) ; a = b = c = 1; printf ( “enter n, r values”); ...

Program for Insertion of an elementt into an array

# include<stdio.h> #include<conio.h> void main() { int a[10],i, j, n , pos , x ; printf ( “enter size of an array”); scanf ("%d", & n); printf ( “enter elements in to an arr...

Program for Deletion of an element in an array.

# include<stdio.h> #include<conio.h> void main() { int a[10],i, j, n , pos , n; printf ( “enter size of an array”); scanf ("%d", & n); printf ( “enter elements into an array...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item