how to write a bubble sort program without using temporary
variable?
Answer Posted / nitin garg
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main()
{
int num[100],n,i,j;
printf("how many elements you enter
");
scanf("%d",&n);
printf("Enter %d elements
",n);
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(num[j]>num[i])
{
num[i]=num[i]+num[j];
num[j]=num[i]-num[j];
num[i]=num[i]-num[j];
}
}
}
printf("
Sorted in Ascending order
");
for(i=0;i<n;i++)
{
printf("%d
",num[i]);
}
getch();
}
Is This Answer Correct ? | 15 Yes | 4 No |
Post New Answer View All Answers
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
Write a program of prime number using recursion.
What does %d do in c?
write a progrmm in c language take user interface generate table using for loop?
How to get string length of given string in c?
Is null valid for pointers to functions?
What are runtime error?
How to write c functions that modify head pointer of a linked list?
Tell us two differences between new () and malloc ()?
How can I delete a file?
Write a program on swapping (100, 50)
What is the use of define in c?
Compare and contrast compilers from interpreters.
What is an arrays?
What is non linear data structure in c?