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 |
UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....
void main() { for(int i=0;i<5;i++); printf("%d",i); } What is the output?..
32 Answers College School Exams Tests, CTS, HCL, iGate, SmartData,
how to convert decimal to hexadecimal without using arrays just loops
Write a c-programe that input one number of four digits and find digits sum?
how to convert decimal to binary in c using while loop without using array
50 Answers Apple, Aptech, Arwen Tech, BCS, C2D Software, CEC,
who was the present cheif governor of reserve bank of india
6 Answers State Bank Of India SBI,
what is exceptions?
How to develop a program using C language to convert 8-bit binary values to decimals. TQ
Using string functions write a program that will accept the name of the capital as input value and will display the corresponding country. ------------------------ Capitals Countries ------------------------ Capitals Countries Ottawa Canada Moscow Russia Rome Italy I can't not get it to run properly
write a profram for selection sort whats the error in it?
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 syntax error?