code for bubble sort?



code for bubble sort?..

Answer / ansar husain

void main()
{
int A[50];
int n,j,t ;
printf("enter the size of array:=>");
scanf("%d",&n);
printf("enter the %d value in array:=>%d",n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(A[i]>A[j])
{
i=a[i];
A[i]=a[j];
A[j]=t;
}
}
}
printf("after the shorting:=>\n");
for(i=0;i<n;i++)
{
printf("%d",A[i]);
}
getch();

Is This Answer Correct ?    1 Yes 6 No

Post New Answer

More C Interview Questions

Differentiate between declaring a variable and defining a variable?

0 Answers  


What does typedef struct mean?

0 Answers  


What is wrong with this initialization?

0 Answers  


Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2)

6 Answers   Subex,


#include<stdio.h> #include<conio.h> int main() { int a[4][4]={{5,7,5,9}, {4,6,3,1}, {2,9,0,6}}; int *p; int (*q)[4]; p=(int*)a; q=a; printf("\n%u%u",p,q); p++; q++; printf("\n%u%u",p,q); getch(); return 0; } what is the meaning of this program?

2 Answers  






Which is the best sort method for library management?

1 Answers   Microsoft,


what is the use of #pragma pack, wer it is used?

2 Answers   Wipro,


What kind of sorting is this? SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort

3 Answers   Accenture,


How can you determine the maximum value that a numeric variable can hold?

0 Answers  


What are the rules for identifiers in c?

0 Answers  


Write a code on reverse string and its complexity.

0 Answers   Expedia,


When should the register modifier be used? Does it really help?

0 Answers  


Categories