to arrange number ascending using bubble sort techniqu


                  /*to arrange number ascending using bubble sort technique*/
#include<stdio.h>
#include<conio.h>
void main()
{
  int num[10];
  int loop,i;
  int last=10;
  int exchange;
  int temp;
 clrscr();
 printf("enter the 10 number\n");
 for(i=0;i<10;++i)
   scanf("%d",&num[i]);
 for(loop=0;loop<9;++loop)
{
    exchange=0;
     for(i=0;i<(last-1);i++)
                 if(num[i]<num[i+1])
                    {
                      temp=num[i];
                      num[i]=num[i+1];
                      num[i+1]=temp;
                      exchange=exchange+1;
                    }
  if(exchange==0)
       break;
 else
      last=(last-1);
 }
printf("number is in descending order: \n");
for(i=0;i<10;i++)
     printf("%d\n",num[i]);
getch();
}


Enter  the 10 number
25
20
6
14
12
32
4
6
8
9
Number is in ascending order:
4
6
6
8
9
12
14
20
25
32
Related Posts Plugin for WordPress, Blogger...