wap for bubble sort
Answers were Sorted based on User's Feedback
Answer / guru1985
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i,j,r,temp;
printf("Enter the Range:");
scanf("%d",&r);
for(i=0;i<r;i++)
{
printf("Enter the Eliment No. %d",i+1);
scanf("%d",&a[i]);
}
for(i=0;i<r;i++)
{
temp=0;
for(j=i+1;j<r;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("After Sorting:");
for(i=0;i<r;i++)
{
printf("\n%d",a[i]);
}
}
| Is This Answer Correct ? | 15 Yes | 4 No |
Answer / mandeep m gaba
//n=No of elements in an array;
int n;
int []a;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{ //swap function for the variables in the array
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
| Is This Answer Correct ? | 11 Yes | 8 No |
Answer / sachin
n=No of elements in an array;
for(i=0;i<n;i++)
{for(j=0;j<n-i;j++)
{if(arr[j]>arr[j+1])
swap(arr[j],arr[j+1]);
}
}
void swap(int*x, int*y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
| Is This Answer Correct ? | 7 Yes | 10 No |
how tally is useful?
How to create a program that lists the capital country when told what the original country is? (Terribly sorry, I'm a novice programmer and would appreciate any help ;). Cheers, Alexxis
void main() { int i=1; printf("%d%d%d",i,++i,i++); } Cau u say the output....?
void main() { int i=7; printf("N= %*d",i,i); }
#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }
void main() { int i=5; printf("%d",i+++++i); }
which typw of errors ? & how to solve it ?
what is exceptions?
What is probability to guarantee that the task a programmer is going to create will be created and be able to run on a particular system (RTOS/GPOS).
what is meant for variable not found?
I am using Qt 5.6 during compilation it stops and gives error about Qmake The process "C:QtQt5.6.35.6.3msvc2015_64inqmake.exe" crashed. Error while building/deploying project untitled1 (kit: Desktop Qt 5.6.3 MSVC2015 64bit) When executing step "qmake"
what is macro in c? Difference between single linked list & double linked list what is fifo & lifo? what is stack & queue?