Dear Sir,
we are required the bubble sorting programs

Regs
Prem



Dear Sir, we are required the bubble sorting programs Regs Prem..

Answer / vignesh1988i

DESCENDING ORDER Bubble sorting

#include<stdio.h>
#include<conio.h>
void main()
{
int a[100],n;
printf("enter the number of elements :");
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n-1;i++)
for(j=0;j<n;j++)
if(a[j]<a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
for(i=0;i<n;i++)
printf("%d\n",a[i]);
getch();
}


thank u

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Interview Questions

program for following output using for loop? 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

8 Answers   Aptech, Infosys,


What is the difference between array and pointer?

0 Answers  


Write a program in c to replace any vowel in a string with z?

0 Answers   IBS,


Is c is a high level language?

0 Answers  


Determine if a number is a power of 2 at O(1).

2 Answers  






How would you rename a function in C?

0 Answers   Tech Mahindra,


What is the meaning of 2d in c?

0 Answers  


what will be the output of this program main() { int i=1; while (i<=10); { i++; } }

11 Answers  


WAP &#8211; represent a char in binary format

4 Answers   Motorola, Wipro,


What is the difference between variable declaration and variable definition in c?

0 Answers  


Write a program to find minimum between three no.s whithout using comparison operator.

4 Answers   IBM,


main() { float a=8.8; double b=8.8; if(a==b) printf("Equal"); else printf("not equal"); getch(); } what is the output? with reason

6 Answers   CSC,


Categories